Extension : How to retrieve a node_id sort_array ?

Author Message

H-Works Agency

Tuesday 30 May 2006 4:26:47 am

Hi all

I am using 'fetchObjectTree' function to export contents to a CSV file in my modified "CSV Extract" extension.

I want to make shure that the sorting of the export is the same as the sorting of the parent folder.

I use 'fetchObjectTree' like this :

$list =& eZContentFunctionCollection::fetchObjectTree($Subtree, $sortBy, false, false, $Offset, $Limit,
$Class_id, false, false, 'include', array($Class_id),
false, false, true, true, true);

My problem is to retrieve the 'sort_array' of a certain node to force the function to order the results the same as the parent node with the $sortBy variable. '$Subtree' is the node_id integer.

This is the code i use to retrieve the sort_array for this node_id :

$myNode =& eZContentObjectTreeNode::fetch($Subtree, false, false);
$sortBy = eZContentObjectTreeNode::sortArrayBySortFieldAndSortOrder($myNode['sort_field'], $myNode['sort_order']);
$sortBy = $sortBy[0];

$sortBy give me the sort_array of the $Subtree node_id

It works but is there a shorter/cleaner way to do the same thing ? Why all those classes/php functions aren't documented ?

Thanx for every help :p

Martin

EZP is Great

Łukasz Serwatka

Thursday 01 June 2006 12:13:49 am

Hi,

You can get sort_array and node_id like:

include_once( 'kernel/classes/ezcontentobjecttreenode.php' );

// {def $node=fetch( 'content', 'node', hash( 'node_id', 2 ) )}
$node =& eZContentObjectTreeNode::fetch( 2 );

// {$node.node_id}
$node->attribute('node_id');

// {$node.sort_array}
$nodeSortArray =& $node->sortArray();
// {$node.parent.sort_array}
$parent =& $node->fetchParent();
$parentSortArray =& $parent->sortArray();

Hope it will help you.

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

H-Works Agency

Thursday 01 June 2006 1:40:20 pm

Thanx Lukas, i am gonna try that.

But if i understand, if i want to only get a node sort_array i should use :

$node =& eZContentObjectTreeNode::fetch( 2 );
$nodeSortArray =& $node->sortArray();

Or do i have to include the following line inbetween :

$node->attribute('node_id');

Well i am gonna try anyway. Thanx a lot for your help.

Martin

EZP is Great

Łukasz Serwatka

Thursday 01 June 2006 1:47:21 pm

No, you don't need to put $node->attribute('node_id'); between. It was just an example how to get node id ;)

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

H-Works Agency

Friday 02 June 2006 11:05:18 am

Ok thanx a lot...it works !

I finally use this code :

$node =& eZContentObjectTreeNode::fetch($node_id);
$sortBy =& $node->sortArray();
$sortBy = $sortBy[0];

I had to add '$sortBy = $sortBy[0];' otherwise it output 'array(array('published',false))' and not just 'array('published',false)' as needed.

Martin

EZP is Great

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 21:01:55
Script start
Timing: Jan 18 2025 21:01:55
Module start 'layout'
Timing: Jan 18 2025 21:01:55
Module start 'content'
Timing: Jan 18 2025 21:01:56
Module end 'content'
Timing: Jan 18 2025 21:01:56
Script end

Main resources:

Total runtime0.6061 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.0469152.6406
Module start 'layout' 0.00610.0025 740.687539.4766
Module start 'content' 0.00860.5962 780.1641578.3359
Module end 'content' 0.60480.0013 1,358.500016.1250
Script end 0.6060  1,374.6250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5300160.0002
Check MTime0.00140.2238160.0001
Mysql Total
Database connection0.00080.130010.0008
Mysqli_queries0.544789.8690630.0086
Looping result0.00050.0818610.0000
Template Total0.579495.620.2897
Template load0.00200.321920.0010
Template processing0.577595.283220.2887
Template load and register function0.00010.017310.0001
states
state_id_array0.00080.133510.0008
state_identifier_array0.00060.100220.0003
Override
Cache load0.00170.2808400.0000
Sytem overhead
Fetch class attribute can translate value0.00080.124320.0004
Fetch class attribute name0.00110.174470.0002
XML
Image XML parsing0.00120.198320.0006
class_abstraction
Instantiating content class attribute0.00000.0037100.0000
General
dbfile0.00160.2580250.0001
String conversion0.00000.001040.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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/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
6content/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: 29
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs