Forums / Developer / subTreeByNodeID function with priority paramter to fetch nodes based on priority ,not working

subTreeByNodeID function with priority paramter to fetch nodes based on priority ,not working

Author Message

Romeo Antony

Wednesday 26 January 2011 5:34:30 am

Hi ,

After a lot of tries, still fails to fetch nodes into a dynamic block based on priority value of nodes.

Always getting results based on publishing time of nodes.

Here is the code I tried.

$nodeID = $parameters['Source'];

$subTreeParameters['SortBy'] = array('priority', true); // to fetch node based on priority value.

$result = eZContentObjectTreeNode::subTreeByNodeID( $subTreeParameters, $nodeID );

But still subTreeByNodeID functions fetch nodes based on publication time and not based on priority value of nodes.

I have checked the

1823 of file ezcontentobjecttreenode.php. But didn't seen the sortby value passed to subTreeByNodeID function. Always sets sortyby parameter as FALSE.

Any ideas will be a great help.

Thanks in advance

Romeo..

Franck Magnan

Wednesday 26 January 2011 12:01:18 pm

Hello Romeo,

can you tell us more about your problem? Which version of eZPublish do you have?

I'have just test this following code in a module/view and it's working

$result = eZContentObjectTreeNode::subTreeByNodeID( array('SortBy' => array('priority', true)), 2 ); 
foreach ($result as $item)
{
    echo $item->Name.'<br/>';
}

--
Developer at Open Wide

Romeo Antony

Thursday 27 January 2011 3:43:27 am

Thanks a lot for helping me Franck.

Ezpublish version is 4.3.0

I am trying to fetch nodes into ezflow dynamic block using fetch class.

Here is the code.

<?php
class eZFlowLatestObjects implements eZFlowFetchInterface
{
public function fetch( $parameters, $publishedAfter, $publishedBeforeOrAt )
{
if ( isset( $parameters['Source'] ) )
{
$nodeID = $parameters['Source'];
$node = eZContentObjectTreeNode::fetch( $nodeID, false, false ); // not as an object
if ( $node && $node['modified_subnode'] <= $publishedAfter )
{
return array();
}
}
else
{
$nodeID = 0;
}
$subTreeParameters = array();
$subTreeParameters['AsObject'] = false;
$subTreeParameters['SortBy'] = array( 'priority', true ); // fetch nodes based on priority
$subTreeParameters['AttributeFilter'] = array(
'and',
array( 'published', '>', $publishedAfter ),
array( 'published', '<=', $publishedBeforeOrAt )
);
if ( isset( $parameters['Class'] ) )
{
$subTreeParameters['ClassFilterType'] = 'include';
$subTreeParameters['ClassFilterArray'] = explode( ';', $parameters['Class'] );
}

// Do not fetch hidden nodes even when ShowHiddenNodes=true
$subTreeParameters['AttributeFilter'] = array( 'and', array( 'visibility', '=', true ) );
$result = eZContentObjectTreeNode::subTreeByNodeID( $subTreeParameters, $nodeID );
$fetchResult = array();
foreach( $result as $item )
{
$fetchResult[] = array( 'object_id' => $item['contentobject_id'],
'node_id' => $item['node_id'],
'ts_publication' => $item['published'] );
}
return $fetchResult;
}
}
?>

But still nodes are fetched based on publishing time and not based on priority.

Any ideas regarding this will be a really a help Franck.

Romeo

Romeo Antony

Thursday 27 January 2011 5:29:41 am

After digging into much more about the same issue , got some points as

by deafult ezflow fetch class fetch nodes and stored in a table based on publication time even if we specified the priority to sort the nodes. So setting priority to sort the nodes in ezflow fetch class's fetch function will not work. Anyone knows about it.Any ideas.

The following thrad says like that.

http://share.ez.no/forums/extensions/ezflow-block-valid-nodes

Romeo Antony

Thursday 27 January 2011 5:44:22 am

Finally I got it. The above thread helped to http://share.ez.no/forums/extensions/ezflow-block-valid-nodes

The below code did the job

  <span>$timeTest</span> <span>=</span> <a href="http://www.php.net/time" mce_href="http://www.php.net/time" target="ez_no_documentation"><span>time</span></a><span>(</span><span>)</span><span>-</span><span>(</span><span>3600</span><span>*</span><span>24</span><span>)</span><span>;</span>



            <span>if</span> <span>(</span> <a href="http://www.php.net/count" target="ez_no_documentation"><span>count</span></a><span>(</span> <span>$result</span> <span>)</span> <span>)</span>
            <span>{</span>
                <span>foreach</span><span>(</span> <span>$result</span> <span>as</span> <span>$item</span> <span>)</span>
                <span>{</span>
                    <span>if</span><span>(</span> <span>!</span><span>$item</span><span>[</span><span>'is_invisible'</span><span>]</span> <span>)</span>
                    <span>$fetchResult</span><span>[</span><span>]</span> <span>=</span> <a href="http://www.php.net/array" target="ez_no_documentation"><span>array</span></a><span>(</span>  <span>'object_id'</span> <span>=></span> <span>$item</span><span>[</span><span>'contentobject_id'</span><span>]</span><span>,</span>
                                             <span>'node_id'</span> <span>=></span> <span>$item</span><span>[</span><span>'node_id'</span><span>]</span><span>,</span>
                                             <span>'ts_publication'</span> <span>=></span> <span>$timeTest</span><span>--</span> <span>)</span><span>;</span> <span>//$item['published']</span>
                <span>}</span>
            <span>}</span>

eZ debug

Timing: Jan 18 2025 02:45:09
Script start
Timing: Jan 18 2025 02:45:09
Module start 'content'
Timing: Jan 18 2025 02:45:10
Module end 'content'
Timing: Jan 18 2025 02:45:10
Script end

Main resources:

Total runtime0.8560 sec
Peak memory usage4,096.0000 KB
Database Queries201

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0105 588.3281180.7734
Module start 'content' 0.01050.6864 769.1016595.1563
Module end 'content' 0.69690.1590 1,364.2578341.2891
Script end 0.8559  1,705.5469 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.01201.3984210.0006
Check MTime0.00190.2255210.0001
Mysql Total
Database connection0.00220.258610.0022
Mysqli_queries0.735385.90472010.0037
Looping result0.00260.30141990.0000
Template Total0.814095.120.4070
Template load0.00971.131920.0048
Template processing0.804393.962520.4021
Template load and register function0.00010.013710.0001
states
state_id_array0.00120.138110.0012
state_identifier_array0.00220.257320.0011
Override
Cache load0.00941.0943920.0001
Sytem overhead
Fetch class attribute can translate value0.00210.242830.0007
Fetch class attribute name0.00150.177070.0002
XML
Image XML parsing0.00130.149830.0004
class_abstraction
Instantiating content class attribute0.00000.0026100.0000
General
dbfile0.00430.5082320.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
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
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs