EZflow block Valid Nodes

Author Message

John Mangadan

Wednesday 14 April 2010 3:14:50 pm

I need to fetch the valid_nodes in a block priority basis instead of default publish date.When I loop over $block.valid_nodes , now its displaying based on publish date. I need to change it to priority.how is it possible?

Thanks,

John

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

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 30 2025 00:46:51
Script start
Timing: Jan 30 2025 00:46:51
Module start 'layout'
Timing: Jan 30 2025 00:46:51
Module start 'content'
Timing: Jan 30 2025 00:46:51
Module end 'content'
Timing: Jan 30 2025 00:46:51
Script end

Main resources:

Total runtime0.0175 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.1328151.2109
Module start 'layout' 0.00520.0040 739.343836.6484
Module start 'content' 0.00920.0065 775.992294.1719
Module end 'content' 0.01570.0017 870.164133.9922
Script end 0.0175  904.1563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002715.5452140.0002
Check MTime0.00116.4250140.0001
Mysql Total
Database connection0.00105.604310.0010
Mysqli_queries0.003821.698930.0013
Looping result0.00000.096810.0000
Template Total0.00126.710.0012
Template load0.00095.248510.0009
Template processing0.00031.453210.0003
Override
Cache load0.00063.402710.0006
General
dbfile0.00137.695680.0002
String conversion0.00000.046440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs