adding location

Author Message

SiXTy

Tuesday 01 November 2005 2:38:21 am

Hi
I'm trying to add new location for object with

$contentObject->createNodeAssignment(1382,0);

but it works for me only when adding main node.
Otherwise it adds empty location.
Can somebody gimme an advice?
Thanks,
Edge

Ɓukasz Serwatka

Tuesday 01 November 2005 11:28:51 pm

Hi,

Use eZNodeAssignment, example below


$objectID = 10;

$object =& eZContentObject::fetch( $objectID );

$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $object->attribute( 'id' ),
'contentobject_version' => $object->attribute( 'current_version' ),
'parent_node' => 123,
'is_main' => 0
)
);
$nodeAssignment->store();

This code will add new location for object 10 under object with nodeID 123.

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

SiXTy

Saturday 05 November 2005 2:33:34 am

Hi
Thanks for reply, I tried your code, but everything is same...it adds empty location...
E.

SiXTy

Saturday 05 November 2005 3:28:26 am

I've fixed the problem by adding $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ),
'version' => $object->attribute( 'current_version' ) ) );

but another problem emerged: the node was added without subnodes. Does anybody know if there's some function for adding node with its children?
Tnx
E.

Mark Marsiglio

Saturday 05 November 2005 9:31:15 am

It is normal behavior (a "feature") for the additional location of a node to not have the same children as the main location.

To get around this problem, we replace fetches for children with fetches of the children of the main node of the object.

In a tree nav, it looks like this...

 {let  nodechildren=fetch(content,list,hash(
                                   parent_node_id,$node_obj.main_node_id,
                                   sort_by,$node_obj.sort_array
))}

The only change is setting the parent node id as the parent object main node id.

It also might require a change in other templates that list children, like Folder.tpl.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

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 11:21:03
Script start
Timing: Jan 18 2025 11:21:03
Module start 'layout'
Timing: Jan 18 2025 11:21:03
Module start 'content'
Timing: Jan 18 2025 11:21:04
Module end 'content'
Timing: Jan 18 2025 11:21:04
Script end

Main resources:

Total runtime0.6851 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.7891152.6094
Module start 'layout' 0.00550.0028 740.398439.4141
Module start 'content' 0.00830.6752 779.8125607.1016
Module end 'content' 0.68350.0016 1,386.914112.1953
Script end 0.6851  1,399.1094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4497160.0002
Check MTime0.00130.1879160.0001
Mysql Total
Database connection0.00080.121710.0008
Mysqli_queries0.626191.3861650.0096
Looping result0.00060.0940630.0000
Template Total0.656495.820.3282
Template load0.00220.319620.0011
Template processing0.654295.477020.3271
Template load and register function0.00010.021010.0001
states
state_id_array0.00070.103410.0007
state_identifier_array0.00080.110320.0004
Override
Cache load0.00160.2349350.0000
Sytem overhead
Fetch class attribute can translate value0.00070.103030.0002
Fetch class attribute name0.00130.189370.0002
XML
Image XML parsing0.00110.162330.0004
class_abstraction
Instantiating content class attribute0.00000.002070.0000
General
dbfile0.00160.2345230.0001
String conversion0.00000.001440.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs