Forums / Extensions / EZflow block Valid Nodes

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

eZ debug

Timing: Jan 18 2025 00:00:04
Script start
Timing: Jan 18 2025 00:00:04
Module start 'content'
Timing: Jan 18 2025 00:00:05
Module end 'content'
Timing: Jan 18 2025 00:00:05
Script end

Main resources:

Total runtime0.9426 sec
Peak memory usage4,096.0000 KB
Database Queries193

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 587.7109180.8359
Module start 'content' 0.00670.7399 768.5469548.6406
Module end 'content' 0.74660.1959 1,317.1875336.9063
Script end 0.9425  1,654.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00540.5706210.0003
Check MTime0.00220.2387210.0001
Mysql Total
Database connection0.00100.110210.0010
Mysqli_queries0.849790.14601930.0044
Looping result0.00260.27141910.0000
Template Total0.896195.120.4480
Template load0.00200.215820.0010
Template processing0.894094.850620.4470
Template load and register function0.00050.057610.0005
states
state_id_array0.00120.132010.0012
state_identifier_array0.00250.270420.0013
Override
Cache load0.00160.1702130.0001
Sytem overhead
Fetch class attribute can translate value0.00160.172530.0005
Fetch class attribute name0.00260.275540.0006
XML
Image XML parsing0.00390.410930.0013
class_abstraction
Instantiating content class attribute0.00000.000940.0000
General
dbfile0.00440.4622330.0001
String conversion0.00000.001030.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs