works now, but I have a couple of issues
1) The page container is created in the correct place but the supposed sub page is not. Instead it appears in the root document tree.
2) what is command to have the container page and/or sub page named after the user ID?
Here is the code below. Thanks
if($mode=="new"){
$table_name = $modx->getFullTableName( 'site_content' );
$fields = array(
'type' => 'document',
'contentType' => 'text/html',
'pagetitle' => 'pagetitle',
'longtitle' => 'my longtitle goes here',
'published' => '0', //is the page published?
'parent' => '54', //what is the parent of this new page?
'isfolder' => '1',
'template' => '4', //type template id here
'cacheable' => '0',
'createdby' => '-".$userid."', // yes the -# is good there webusers are -# because manager users are +#
'createdon' => '".time()."',
'editedon' => '".time()."',
'publishedon' => '".time()."',
'hidemenu' => '1'
);
$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
//Create placeholder and put the id in a session to use for mail or whatever.
$_SESSION['eigenpaginaid'] = $modx->db->getInsertId();
$modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
//start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
$fields = array(
'type' => 'document',
'contentType' => 'text/html',
'pagetitle' => 'pagetitle',
'longtitle' => 'my longtitle goes here',
'published' => '1', //is the page published?
'parent' => $parent, //here we go create a doc in the first doc
'isfolder' => '0',
'template' => '1', //type template id here
'cacheable' => '0',
'createdby' => $wuid,
'createdon' => time(),
'editedon' => time(),
'publishedon' => time(),
'hidemenu' => '1'
);
$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
//end of page creation
return;
}
This question was asked by Rossco but the solution of adding $parent (which was already in the code) didn’t work for me :-(