This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Setup & design » nodeassignment and treenode

nodeassignment and treenode

nodeassignment and treenode

Monday 20 March 2006 5:32:31 pm - 10 replies

i'm trying to assign a new node to my contentobjects with a script. whenever i use the following code:

$nodeAssignment =& eZNodeAssignment::create( array(
        		              'contentobject_id' => $cobj->attribute( 'id' ),
        		              'contentobject_version' => $cobj->attribute( 'current_version' ),
                                   'parent_node' => $parentNodeID,
        		              'sort_field' => 2,
        		              'sort_order' => 0,
        		              'is_main' => 0

now my node assignment is created in the table eznode_assignment table.
but no new treenode is created and therefore the the new node isn't really added.
can anybody tell me what i'm missing?

Monday 20 March 2006 6:45:51 pm

'is_main' => 0

Try changing this to 'is_main'=>1.

Monday 20 March 2006 8:53:11 pm

You'll have to call the publish operation of the content module. See

Tuesday 21 March 2006 10:03:49 am

thanks for the replies. i did publish the object - without success. it may be a problem that i do not create a new version when i edit my objects. i just get the current version and the contentobjectattributes of that version. then i set new values for some attributes and try to add a node assignment before i call the publish operation..

Tuesday 21 March 2006 12:28:09 pm

If I remember well, the operation result is stored for each content object version. If you try to publish a specific version for a second time then the operation won't do anything.

Try to create a new version, add a node assignment for the new version and run the publish operation on that version.

Tuesday 21 March 2006 4:48:53 pm

that sounds like a good advice. i'll give it a try. thanks!

Wednesday 22 March 2006 6:44:02 pm

well - still doesn't work..version is created fine. attributes of that version are created fine. but the version status is still 0 even after publishing.

could it be a permission problem? i used the code:

$user =& eZUser::instance(14);

which i'm sure is wrong..but worked for the version creation..

Wednesday 22 March 2006 7:26:49 pm

I have had good luck with this approach.

                //Where to place the object
	// inital values
	$user_id = 14;
	$GroupID = 13;

                //Get the user node and node_id
	include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
	$user =& eZUser::fetch($user_id);
	$user_id = $user->attribute( 'contentobject_id' );
	$userObject =& eZContentObject::fetch($user_id);
	$user_node =& $userObject->attribute('main_node');

<b>Code adapted from:
// Copyright (C) 1999-2004 Björn Dieding, xrow GbR Germany. All rights reserved.
run this script from the shell

php -C create.php


Thursday 23 March 2006 3:48:00 pm

ok, my problem was that i used:

$script =& eZScript::instance( array( 'description' => ( "pieps" ),
                                      'use-session' => false,
                                      'use-modules' => true,
                                      'use-extensions' => true ) );

without 'use-modules' => true,
so the publish operation for rhe content module wasn't able to run properly.

Thursday 23 March 2006 10:48:35 pm

Good job!

Friday 13 December 2013 12:33:21 pm

i will see that poast again it is informativ


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

36 542 Users on board!

Forums menu

Proudly Developed with from