Create page by user with attributes?

Permalink
Hello,
It is possible when user submit a form, it will creates a page with specific attributes?
I know how to create a page but how to pass the values to attributes and assign them??
Any Ideas or suggestions?

Sorry if I am repeating the thread but couldn't find anything similar.

sergio11ofpp
 
sergio11ofpp replied on at Permalink Reply
sergio11ofpp
no advice?
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
sergio11ofpp replied on at Permalink Reply
sergio11ofpp
Thank you Rony! :)
THis will add a new attribute to a page
Can you look at this code?
$parentPage = Page::getByPath("/hotel");
      $ct = CollectionType::getByHandle("products");
      $data = array();
      $data['cName']        = 'Test Page';
      $data['cDescription'] = 'Description';
      $newPage = $parentPage->add($ct, $data);

I get an error in MySql But I saw in Documentation this how you add a new page it seems to me cant find an error((
mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1] in EXECUTE("select max(cDisplayOrder) from Pages where cParentID = LIMIT 1")


Thank you again!
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Try this:

$pData = array('uID' => 1, 'pkgID' => 0, 'cName' => 'Test Page', 'cHandle' => 'testfive', 'cDatePublic' => '2013-07-02');
$oPage = Page::getByPath('/hotel');
$ct = CollectionType::getByHandle('products');
$newPage = $oPage->add($ct, $pData);


Rony
sergio11ofpp replied on at Permalink Reply
sergio11ofpp
No Luck same error.
ronyDdeveloper replied on at Permalink Best Answer Reply
ronyDdeveloper
Make it sure that you have a page with the path "/hotel" as well as a page type handle called "products".

Rony
sergio11ofpp replied on at Permalink Reply
sergio11ofpp
Ohhh I got It
Loader::model('collection_types');
      Loader::model('page'); 
      $dt = Loader::helper('form/date_time');

Needed to load this guys))

ROny Thank you for spending your time to help me!!
One last question if you know how can I combine adding page and adding attribute.
I mean when I create page )
sergio11ofpp replied on at Permalink Reply
sergio11ofpp
Problem Solved:
$dt = Loader::helper('form/date_time'); //current date
$ct = CollectionType::getByHandle('Products'); // page type
// array of data
$data = array();
$data['uID'] = 1;
$data['pkgID'] = 0;
$data['cName'] = 'Page Name';
$data['cHandle'] = 'new_page_handle'; $data['cDatePublic'] = $dt->translate('cDatePublic');
// get by path parent page :)
$page  = Page::getByPath('/hotel');
$newpage = $page->add($ct, $data);
$newpage->setAttribute('city', $city);