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