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.

eZ debug

Timing: Jan 19 2025 15:09:44
Script start
Timing: Jan 19 2025 15:09:44
Module start 'layout'
Timing: Jan 19 2025 15:09:44
Module start 'content'
Timing: Jan 19 2025 15:09:45
Module end 'content'
Timing: Jan 19 2025 15:09:45
Script end

Main resources:

Total runtime1.0065 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 589.1563152.6250
Module start 'layout' 0.00510.0028 741.781339.4453
Module start 'content' 0.00790.9970 781.2266562.6875
Module end 'content' 1.00490.0015 1,343.914116.1641
Script end 1.0065  1,360.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3156160.0002
Check MTime0.00140.1342160.0001
Mysql Total
Database connection0.00070.064910.0007
Mysqli_queries0.952994.6731630.0151
Looping result0.00050.0489610.0000
Template Total0.976397.020.4882
Template load0.00180.175420.0009
Template processing0.974596.823320.4873
Template load and register function0.00010.012310.0001
states
state_id_array0.00100.103310.0010
state_identifier_array0.00130.124820.0006
Override
Cache load0.00150.1502400.0000
Sytem overhead
Fetch class attribute can translate value0.00050.045620.0002
Fetch class attribute name0.00090.085860.0001
XML
Image XML parsing0.00060.055320.0003
class_abstraction
Instantiating content class attribute0.00000.001980.0000
General
dbfile0.00220.2187160.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs