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

Wednesday 26 January 2011 5:34:30 am - 4 replies

Modified on Wednesday 26 January 2011 6:31:23 am by Romeo Antony

Author Message

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>

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.