Forums / Developer / Tree Node Assignment

Tree Node Assignment

Author Message

Julien Fieutelot

Monday 23 January 2006 2:26:51 am

Hi,

I want to insert an object in a node. But it's doesn't work, but I have no error report and no process error.

$class =& eZContentClass::fetch(21);
$customer =& $class->instantiate(15);

$nodeAssignment =& eZNodeAssignment::create( 
	array( 
    'contentobject_id' => $customer->attribute( 'id' ), 
    'contentobject_version' => 1,
    'parent_node' => $parent_node_id, 
    'is_main' => 1
  ) 
); 
$nodeAssignment->store(); 

$version =& $customer->version( 1 ); 
$version->setAttribute( 'modified', eZDateTime::currentTimeStamp() ); 
$version->setAttribute( 'status', EZ_VERSION_STATUS_PUBLISHED ); 
$version->store(); 

$db = & eZDB::instance();

$customers = $db->arrayQuery("SELECT * FROM customer WHERE code='$custNumber'");

if( $customers ) {
	$contentObjectAttributes =& $version->contentObjectAttributes();
	$contentObjectAttributes[0]->setAttribute('data_text', $customers[0]['name']);
	$contentObjectAttributes[0]->store();
	
	$contentObjectAttributes[1]->setAttribute('data_text', $customers[0]['code']);
	$contentObjectAttributes[1]->store();
	
	$customer->store();
}

This is the whole proccess with $customer object. This part doesn't work but I don't know why ?...The $customer object is not null and contains the required value. The query result is right too. Is there an error in eZNodeAssignment::create ? Do I forget parameters ? Or is the second parameter section for $class->instantiate required ?

Thanks for your help
Julien

Łukasz Serwatka

Monday 23 January 2006 3:24:49 am

It looks like your code is missing with at the end:

include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
...
...
//publish new object
 $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $customer->attribute( 'id' ),
'version' => 1 ) );

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Julien Fieutelot

Monday 23 January 2006 4:48:51 am

It works fine now.

Thanks
Julien

Sébastien Antoniotti

Sunday 11 February 2007 12:42:55 pm

Hi,

I'm using your code, all is right, but I need to know the node_id of the node added precedently. Is there any way to do this ?

eZ Publish Freelance
web : http://www.webaxis.fr

Bruce Morrison

Sunday 11 February 2007 3:29:22 pm

Hi Sébastien

Adding

$nodeID = $customer->attribute('main_node_id');

after the end will do the trick.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Sébastien Antoniotti

Sunday 11 February 2007 9:58:57 pm

Hi Bruce,

Many thanks !

Good webdev ;-)

eZ Publish Freelance
web : http://www.webaxis.fr

eZ debug

Timing: Jan 20 2025 20:18:15
Script start
Timing: Jan 20 2025 20:18:15
Module start 'content'
Timing: Jan 20 2025 20:18:15
Module end 'content'
Timing: Jan 20 2025 20:18:15
Script end

Main resources:

Total runtime0.1005 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 587.6094180.8438
Module start 'content' 0.00510.0044 768.4531101.9609
Module end 'content' 0.00950.0909 870.4141531.7344
Script end 0.1005  1,402.1484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00303.0013200.0002
Check MTime0.00121.2156200.0001
Mysql Total
Database connection0.00070.678510.0007
Mysqli_queries0.064464.09161410.0005
Looping result0.00070.67371390.0000
Template Total0.090790.210.0907
Template load0.00070.731110.0007
Template processing0.090089.472510.0900
Override
Cache load0.00050.481410.0005
Sytem overhead
Fetch class attribute can translate value0.00050.507310.0005
XML
Image XML parsing0.00020.241710.0002
General
dbfile0.00605.9636200.0003
String conversion0.00000.003830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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