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

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 31 2025 06:19:46
Script start
Timing: Jan 31 2025 06:19:46
Module start 'layout'
Timing: Jan 31 2025 06:19:46
Module start 'content'
Timing: Jan 31 2025 06:19:47
Module end 'content'
Timing: Jan 31 2025 06:19:47
Script end

Main resources:

Total runtime0.7939 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.0313151.1953
Module start 'layout' 0.00530.0029 739.226636.6172
Module start 'content' 0.00820.7845 775.84381,058.0078
Module end 'content' 0.79270.0012 1,833.851615.8750
Script end 0.7938  1,849.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.3757160.0002
Check MTime0.00120.1530160.0001
Mysql Total
Database connection0.00090.110510.0009
Mysqli_queries0.728791.7878700.0104
Looping result0.00070.0830680.0000
Template Total0.760995.820.3804
Template load0.00190.243620.0010
Template processing0.758995.596020.3795
Template load and register function0.00120.153410.0012
states
state_id_array0.00120.145610.0012
state_identifier_array0.00120.154520.0006
Override
Cache load0.00160.2039340.0000
Sytem overhead
Fetch class attribute can translate value0.00080.105440.0002
Fetch class attribute name0.00180.224290.0002
XML
Image XML parsing0.00340.427440.0008
class_abstraction
Instantiating content class attribute0.00000.0021100.0000
General
dbfile0.00520.6537300.0002
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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.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