Gaetano Giunta
Moderated by: Nicolas Pastorino
|
Thursday 15 April 2010 1:36:15 am
You should not try to alter the priority within the template, but rather within the function that is used to put the nodes in the block queue. This involves creating a new block fetch function. In its results array, the ts_publication variable is the one that can be used to do the propert sorting, albeit in a 'hackish' mode. Here's the code:
class allchildren extends eZFlowFetchInterface {
/*** we return all the children when some content has changed in the subtree of the param node
*
* It expects the params from block:
* Source int a NodeId
* Class string a ';' separated list of classes for the grouping (optional, if not given all classes are taken into account)
*
* @todo add a parameter to specify the min, max depth to the fetch?
*/
public function fetch( $parameters, $publishedAfter, $publishedBeforeOrAt )
{
if ( isset( $parameters['Source'] ) )
{
$nodeID = $parameters['Source'];
//selection of the parent node with his attribute. This way, we can sort the children same as the back office order
$nodeSource = eZContentObjectTreeNode::fetch( $nodeID );
$sortBy = eZContentObjectTreeNode::sortArrayBySortFieldAndSortOrder($nodeSource->attribute('sort_field'), $nodeSource->attribute('sort_order'));
$subTreeParameters = array();
$subTreeParameters['AsObject'] = false;
$subTreeParameters['Depth'] = 1;
$subTreeParameters['SortBy'] = $sortBy[0];
// $subTreeParameters['IgnoreVisibility'] = false;
$subTreeParameters['AttributeFilter'] = array(
'and',
array( 'modified', '>', $publishedAfter ),
array( 'modified', '<=', $publishedBeforeOrAt )
);
if ( isset( $parameters['Class'] ) && $parameters['Class'] != "" )
{
$subTreeParameters['ClassFilterType'] = 'include';
$subTreeParameters['ClassFilterArray'] = explode( ';', $parameters['Class'] );
}
$result = eZContentObjectTreeNode::subTreeByNodeID( $subTreeParameters, $nodeID );
$fetchResult = array();
/*
* ezFlow stores the result ($fetchResult[]) in a table. The results are sorted by the ts_publication.
* For having the same order than the back office, it's mandatory to modify the ts_publication of each item of the $fetchResult.
* It's done by using the $timeTest variable.
*/
$timeTest = time()-(3600*24);
if ( count( $result ) )
{
foreach( $result as $item )
{
if( !$item['is_invisible'] )
$fetchResult[] = array( 'object_id' => $item['contentobject_id'],
'node_id' => $item['node_id'],
'ts_publication' => $timeTest-- ); //$item['published']
}
}
return $fetchResult;
}
else
{
/// @todo log error!
return array();
}
}
}
Principal Consultant International Business
Member of the Community Project Board
|