Forums / Setup & design / nodeassignment and treenode

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!

eZ debug

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

Main resources:

Total runtime0.9150 sec
Peak memory usage4,096.0000 KB
Database Queries217

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 587.7109180.8359
Module start 'content' 0.00650.8015 768.5469667.2109
Module end 'content' 0.80800.1069 1,435.7578344.4375
Script end 0.9149  1,780.1953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4195210.0002
Check MTime0.00140.1563210.0001
Mysql Total
Database connection0.00110.116610.0011
Mysqli_queries0.837791.55322170.0039
Looping result0.00210.22432150.0000
Template Total0.889297.220.4446
Template load0.00200.222520.0010
Template processing0.887196.952620.4436
Template load and register function0.00020.018110.0002
states
state_id_array0.00110.122110.0011
state_identifier_array0.00080.084620.0004
Override
Cache load0.00180.1940500.0000
Sytem overhead
Fetch class attribute can translate value0.00110.121340.0003
Fetch class attribute name0.00100.1054120.0001
XML
Image XML parsing0.00150.163240.0004
class_abstraction
Instantiating content class attribute0.00000.0028150.0000
General
dbfile0.00310.3368330.0001
String conversion0.00000.000830.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0005 secs