eZ Community » Forums » General » Creating new root node ?
expandshrink

Creating new root node ?

Creating new root node ?

Monday 28 January 2008 3:32:14 pm - 3 replies

Hello,

How is it possible to create a new node, for customs contents, under node_id '1' ?

It would be at the same depth as "Contents, Users, Design...Etc"

Thanx in advance.

Tuesday 29 January 2008 8:16:46 pm

You actually mean root node or a top level node?

If the latter, I've already done some experiments:
http://ez.ryba.eu/index.php/ez_pu...is_that_possible_round_i_exploration
Unfortunately, didn't find time to push it to a more practical dimension blunk.gif Emoticon
There should be some other works if you look.

If you mean root node, then I might be wrong, but don't think so. The root node has contentobject_id reference equal 0, and there is no contentobject corresponding, which from my experience suggests that root node is purely virtual. It might be called in a fixed way or never called at all, it might be there for tree structuring/recursing only.

Modified on Tuesday 29 January 2008 8:18:53 pm by Piotr Karaƛ

Monday 07 July 2008 2:15:44 pm

I was speaking of top-level nodes.

I've read your article and the answer seems to be negative.

For example i have a website with a "reservation" function. Those contents are neither webcontents, or else but uses ezp classes and must thus be inside ezp content tree.

It would be nice if i could have moved all those reservations into a new top-level node and make a custom module accessing them.

Monday 07 July 2008 2:26:28 pm

somthing like this will do the job...

<?php
include_once( 'lib/ezutils/classes/ezcli.php' );
include_once( 'kernel/classes/ezscript.php' );
$cli =& eZCLI::instance();
$script =& eZScript::instance( array( 'description' => ( "Content Server Client setup script\n" .
                                                         "creates the incomming node for the content server client\n" .
                                                         "\n" .
                                                         "./extension/contentserver/bin/createincommingnode.php -ssiteaccessname" ),
                                      'use-session' => true,
                                      'use-modules' => true,
                                      'use-extensions' => true ) );

$script->startup();

$options = $script->getOptions( "[admin-user:]",
                                "",
                                array( 'admin-user' => 'Admin user login name' ) );

$script->initialize();

include_once( 'kernel/classes/ezcontentobject.php' );
include_once( 'kernel/classes/ezsection.php' );
// login as admin
include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
$user = eZUser::fetchByName( $options['admin-user'] );

if ( is_object( $user ) )
{
	if ( $user->loginCurrent() )
	   $cli->output( "Logged in as 'admin'" );
}
else
{
	$cli->error( 'No admin.' );
    $script->shutdown( 1 );
}
$section = new eZSection( array( 'name' => 'Content server', 'navigation_part_identifier' => 'ezcontentservernavigationpart' ) );
$section->store();
$userClassID = 1;
$userCreatorID = 14;
$defaultSectionID = $section->ID;

$class = eZContentClass::fetch( $userClassID );
$contentObject = $class->instantiate( $userCreatorID, $defaultSectionID );

$remoteID = "contentserver:incomingnode";
$contentObject->setAttribute( 'remote_id', $remoteID );
$contentObject->store();

$contentObjectID = $contentObject->attribute( 'id' );
$userID = $contentObjectID;
$nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $contentObjectID,
'contentobject_version' => 1,
'parent_node' => 1,
'is_main' => 1 ) );
$nodeAssignment->store();
$version =& $contentObject->version( 1 );
$version->setAttribute( 'modified', time() );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->store();

$contentObjectID = $contentObject->attribute( 'id' );
$contentObjectAttributes = $version->contentObjectAttributes();

$contentObjectAttributes[0]->setAttribute( 'data_text', 'Incoming' );
$contentObjectAttributes[0]->store();

include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
'version' => 1 ) );

$cli->output( "Node created with object_id #$contentObjectID" );

return $script->shutdown();
?>
expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from