How to assign nodes using PHP

Author Message

Eirik Alfstad Johansen

Friday 30 July 2004 2:29:07 am

Hi,

Armed with a the id and version of an object as well as an array of parent nodes, I'm trying to assign nodes to the object after its creation (using a workflow set to trigger at content|publish|after). The code I'm using is the following:

$nodeAssignment =& eZNodeAssignment::create( array('contentobject_id' => $object['id'],
                                            'contentobject_version' => $object['current_version'],
                                            'parent_node' => $v,
                                            'sort_field' => 2,
                                            'sort_order' => 0,
                                            'is_main' => 0));
				
$nodeAssignment->store();

However, it doesn't seem to work, neither do I get any errors in the DebugOutput. I have, of course, already made sure that the variables used are populated. Am I perhaps missing some code?

Thanks in advance !

Sincerely,

Eirik Johansen
http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Paul Forsyth

Friday 30 July 2004 2:35:14 am

You need to publish the object:

$operationResult = eZOperationHandler::execute( 'content', 
                                                'publish',
                                                array( 'object_id' => $object['id'],
                                                       'version' => $object['current_version']) );

paul

--
http://www.visionwt.com

Eirik Alfstad Johansen

Friday 30 July 2004 2:52:24 am

Hi Paul,

But shouldn't the object already be published since the event is run on the content|publish|after trigger?

Sincerely,

Eirik Johansen
http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Eirik Alfstad Johansen

Friday 30 July 2004 2:58:02 am

BTW, it did, of course, work.

Thanks a lot, Paul!

Sincerely,

Eirik Johansen
http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Paul Forsyth

Friday 30 July 2004 3:13:49 am

I see, i thought at first you were creating a new object...

Running the excute will update the object with a new version i believe.

But just a simple store() should work i think. If you run store, without the execute, can you see the db row in ezcontentobject_tree corresponding to your new entry?

eZ, can you comment?

paul

--
http://www.visionwt.com

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