nodeassignment and treenode

Author Message

andre müller

Monday 20 March 2006 8:32:31 am

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
        		              )
        		              );
$nodeAssignment->store();

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?
thanks!

Betsy Gamrat

Monday 20 March 2006 9:45:51 am

'is_main' => 0

Try changing this to 'is_main'=>1.

Kristof Coomans

Monday 20 March 2006 11:53:11 am

You'll have to call the publish operation of the content module. See http://ez.no/community/forum/developer/insert_objects_from_module_clear_cache_problem/.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

andre müller

Tuesday 21 March 2006 1: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..

Kristof Coomans

Tuesday 21 March 2006 3:28:09 am

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.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

andre müller

Tuesday 21 March 2006 7:48:53 am

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

andre müller

Wednesday 22 March 2006 9:44:02 am

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);
$user->loginCurrent();

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

Betsy Gamrat

Wednesday 22 March 2006 10:26:49 am

I have had good luck with this approach.

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

                //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

*/
</b>

andre müller

Thursday 23 March 2006 6:48:00 am

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.

Betsy Gamrat

Thursday 23 March 2006 1:48:35 pm

Good job!

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 18 2025 20:58:41
Script start
Timing: Jan 18 2025 20:58:41
Module start 'layout'
Timing: Jan 18 2025 20:58:41
Module start 'content'
Timing: Jan 18 2025 20:58:42
Module end 'content'
Timing: Jan 18 2025 20:58:42
Script end

Main resources:

Total runtime1.0562 sec
Peak memory usage4,096.0000 KB
Database Queries80

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 587.9141152.6250
Module start 'layout' 0.00630.0033 740.539139.4453
Module start 'content' 0.00961.0451 779.9844662.1328
Module end 'content' 1.05470.0014 1,442.117220.1641
Script end 1.0562  1,462.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3150160.0002
Check MTime0.00130.1229160.0001
Mysql Total
Database connection0.00060.054410.0006
Mysqli_queries0.972592.0759800.0122
Looping result0.00090.0859780.0000
Template Total1.022296.820.5111
Template load0.00220.209320.0011
Template processing1.020096.569720.5100
Template load and register function0.00020.016710.0002
states
state_id_array0.00090.082610.0009
state_identifier_array0.00120.110020.0006
Override
Cache load0.00210.2002500.0000
Sytem overhead
Fetch class attribute can translate value0.00100.092930.0003
Fetch class attribute name0.00120.1109120.0001
XML
Image XML parsing0.00250.238430.0008
class_abstraction
Instantiating content class attribute0.00000.0040150.0000
General
dbfile0.00240.2251220.0001
String conversion0.00000.000940.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
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
16content/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
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/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: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs