Forums / Extensions / eZ Flow / Get eZ Flow zones of an object

Get eZ Flow zones of an object

Author Message

Michael Fürmann

Monday 25 July 2011 5:48:17 am

Hey there,

for a navigation on our site I need to fetch a specific zone and the included blocks from some objects in our eZ Publish installation.

Can you tell me how I can fetch the blocks in this zone?

I tried to inspect the whole object using attribute(show), but I only found this output by using
{$object.children[0].data_map.page.content.zones|attribute(show)}

Attribute Type Value
0 object[eZPageZone] Object
>id string 'a52658c8b1d003bbbe6dc542108dd534'
>zone_identifier string 'main'
1 object[eZPageZone] Object
>id string '3893870da1d595349061a4bba3fd1be7'
>zone_identifier string 'guide'
2 object[eZPageZone] Object
>id string 'f43306e22fb45f1ed72ce3b7276c39d9'
>zone_identifier string 'keyvis'

Well, I got the zone ID ...
Is there a fetch to get the zone and the blocks behind this ID?

Regards from Germany,
Michael Fürmann

Benjamin Choquet

Monday 25 July 2011 7:59:41 am

Hi Michael,

the eZPageZone object contains your blocks. You should loop on the zones to get the desired one and then output its blocks. Assuming you're looking for the guide zone it should be something like that :

{foreach(  $object.children[0].data_map.page.content.zones as $zone}
  {if $zone.zone_identifier|eq('guide')}
    {foreach $zone.blocks as $block}
     {block_view_gui block=$block}
    {/foreach}
    {break}
  {/if}
{/foreach}

Michael Fürmann

Tuesday 26 July 2011 12:08:12 am

Thank you for your suggestion, but it doesn't work.

I'm not in a module content but in the file pagelayout.tpl.
I did a fetch on a content object which holds my navigation structure.
From some of its children I need to fetch the eZFlow zones and blocks to include them into navigation.

But if I inspect the object using |attribute I can only see the values 'id' and 'zone_identifier' for the zones on the page.
There is no array 'blocks' that could be iterated using foreach.

Steven E. Bailey

Tuesday 26 July 2011 1:26:02 am

Are you sure you're looking at what you think you're looking at?

For my eZPageZone objects (that have blocks) I also get the array "blocks" containing eZPageBlock objects.

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Michael Fürmann

Tuesday 26 July 2011 2:13:56 am

What else should I look at?

I did a fetch to get the root nodes for the navigation:

 $root_items = fetch('content', 'list',
                           hash('parent_node_id', 2,
                                   'sort_by', array( 'priority', false() ),
                                'attribute_filter', array("and", array("node_id", "in", $root_nodes))
                           ) 
                    )

There is an attribute 'page' that is type 'Layout' and holds the zones for eZFlow (right?)
So I iterate the root items for my navigation.
Each of the root items has some children, each of them has a eZFlow layout in attribute 'page'.
I can see values for id and zone_identifier as shown above, but no blocks array.

 {foreach $root_items as $object}
        <li class="navnode">
             <a href={$object.data_map.url_alias|ezurl}  class="navlink">{$object.data_map.title.data_text|wash(xhtml)}</a>
             {if $object.children|count|gt(0)}
            <div  class="navnode">
                {include  uri='design:controls/nav_lvl1.tpl' elements=$item.children}
                 <div class="navnode subnode">
                      <div  class="c9" style="background: white;">
                     {foreach $object.children[0].data_map.page.content.zones as $zone}
                       {if $zone.zone_identifier|eq('guide')}
                         <!-- GUIDE
                        {$zone|attribute(show)}
                         {foreach $zone.blocks as $block}
                          {block_view_gui block=$block}
                        {/foreach}
                         -->
                        {break}
                       {/if}
                    {/foreach}
                       </div>
                </div>
                <div  class="nav_end"></div>
            </div>
             {/if}
        </li>
        {/foreach}

Steven E. Bailey

Tuesday 26 July 2011 3:52:07 am

Your code looks fine as far as the logic goes (as far as I can tell) - although I've never tried to get the datamap of a zone of a child...  Actually, is the $object.children[0] correct? I don't know off the top of my head...

That's what I mean by are you sure you are looking at what think you are looking at... or are you picking up the first child of the $root_item and it just happens to have zones but no blocks?  If you go directly to the node (instead of 2) and don't try to get the attribute of the child, do you get blocks?

Also, what version of ezflow are you using?

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

eZ debug

Timing: Jan 17 2025 22:46:30
Script start
Timing: Jan 17 2025 22:46:30
Module start 'content'
Timing: Jan 17 2025 22:46:30
Module end 'content'
Timing: Jan 17 2025 22:46:30
Script end

Main resources:

Total runtime0.1822 sec
Peak memory usage4,096.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0093 588.9688180.7891
Module start 'content' 0.00940.0057 769.7578107.8047
Module end 'content' 0.01500.1671 877.5625543.0859
Script end 0.1821  1,420.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00361.9830200.0002
Check MTime0.00140.7435200.0001
Mysql Total
Database connection0.00110.597210.0011
Mysqli_queries0.132672.76821410.0009
Looping result0.00160.87201390.0000
Template Total0.166691.510.1666
Template load0.00090.501110.0009
Template processing0.165790.958210.1657
Override
Cache load0.00060.344710.0006
Sytem overhead
Fetch class attribute can translate value0.00080.423810.0008
XML
Image XML parsing0.00030.159110.0003
General
dbfile0.00170.9221200.0001
String conversion0.00000.004230.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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