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

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 18 2025 01:04:50
Script start
Timing: Jan 18 2025 01:04:50
Module start 'layout'
Timing: Jan 18 2025 01:04:50
Module start 'content'
Warning: PHP: E_DEPRECATED Jan 18 2025 01:04:50
trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/ze/public_html/share.se7enx.com/var/community/cache/template/compiled/table-02cf899a6d707917c58210ed54ffe2ff.php on line 147
Timing: Jan 18 2025 01:04:50
Module end 'content'
Timing: Jan 18 2025 01:04:50
Script end

Main resources:

Total runtime0.1749 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.0547152.6406
Module start 'layout' 0.00500.0034 740.695339.4844
Module start 'content' 0.00830.1653 780.1797652.3438
Module end 'content' 0.17360.0012 1,432.523420.3516
Script end 0.1748  1,452.8750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.0889160.0002
Check MTime0.00140.7781160.0001
Mysql Total
Database connection0.00070.427210.0007
Mysqli_queries0.086249.2864700.0012
Looping result0.00060.3359680.0000
Template Total0.142981.720.0714
Template load0.00231.295220.0011
Template processing0.140680.407020.0703
Template load and register function0.00010.064610.0001
states
state_id_array0.00090.515410.0009
state_identifier_array0.00070.401920.0004
Override
Cache load0.00221.2299820.0000
Sytem overhead
Fetch class attribute can translate value0.00060.362530.0002
Fetch class attribute name0.00100.581970.0001
XML
Image XML parsing0.00080.432330.0003
class_abstraction
Instantiating content class attribute0.00000.009880.0000
General
dbfile0.00170.9680170.0001
String conversion0.00000.004640.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/th.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/th.tplEdit templateOverride template
10content/datatype/view/ezxmltags/tr.tpl<No override>extension/community/design/community/templates/content/datatype/view/ezxmltags/tr.tplEdit templateOverride template
9content/datatype/view/ezxmltags/td.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/td.tplEdit templateOverride template
1content/datatype/view/ezxmltags/table.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/table.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 52
 Number of unique templates used: 11

Time used to render debug report: 0.0001 secs