Creating new root node ?

Author Message

H-Works Agency

Monday 28 January 2008 6:32:14 am

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.

EZP is Great

Piotrek Karaś

Tuesday 29 January 2008 11:16:46 am

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_publish/lab/custom_top_level_nodes_is_that_possible_round_i_exploration
Unfortunately, didn't find time to push it to a more practical dimension ;)
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.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

H-Works Agency

Monday 07 July 2008 5:15:44 am

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.

EZP is Great

Björn Dieding@xrow.de

Monday 07 July 2008 5:26:28 am

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();
?>

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:08:42
Script start
Timing: Jan 18 2025 19:08:42
Module start 'layout'
Timing: Jan 18 2025 19:08:42
Module start 'content'
Timing: Jan 18 2025 19:08:42
Module end 'content'
Timing: Jan 18 2025 19:08:42
Script end

Main resources:

Total runtime0.0217 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0094 587.8047152.6094
Module start 'layout' 0.00940.0036 740.414139.4141
Module start 'content' 0.01310.0065 779.828197.4141
Module end 'content' 0.01960.0021 877.242238.3047
Script end 0.0217  915.5469 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002913.1745140.0002
Check MTime0.00125.5713140.0001
Mysql Total
Database connection0.00157.123710.0015
Mysqli_queries0.004822.259930.0016
Looping result0.00000.073510.0000
Template Total0.00177.910.0017
Template load0.00094.058310.0009
Template processing0.00083.827910.0008
Override
Cache load0.00062.889910.0006
General
dbfile0.00156.778180.0002
String conversion0.00000.042840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs