Display all locations

Author Message

Christian Johansen

Thursday 09 March 2006 6:13:01 am

Hi, I want to display all the locations for an object and I want to do it efficiently... The only way I could think of so far is this:

{foreach $node.object.parent_nodes as $parent_node_id}
{let $parent_node=fetch( 'content', 'node', 
                          hash( 'node_id', $parent_node_id ) )}
<a href={$parent_node.url_alias}>{$parent_node.name} ({$:index})</a>, 
{/let}
{/foreach}

Which seems to cause eZ to issue no less than 21 queries for 5 articles which I find a bit steep. There must be an easier way to accomplish this?

Kåre Køhler Høvik

Thursday 09 March 2006 7:03:41 am

Hi

Try this :

{foreach $node.object.assigned_nodes as $location}
<a href={$location.url_alias|ezurl}>{$location.name|wash}</a><br />
{/foreach}

Kåre Høvik

Christian Johansen

Thursday 09 March 2006 7:32:34 am

I tried that earlier, and fetches the same object in its respective locations which is not really what I want - I want all the parent locations. If I have this:

Someobject

Locations:
Topic - SomeTopic - Someobject
Topic - SomeOtherTopic - Someobject

Then I want to do this:

Someobject
- <a href="/topic/sometopic">SomeTopic</a>
- <a href="/topic/someothertopic">SomeOtherTopic</a>

But with your suggestion I get this:

Someobject
- <a href="/topic/sometopic/someobject">SomeObject</a>
- <a href="/topic/someothertopic/someobject">SomeObject</a>

Marc Boon

Saturday 11 March 2006 3:10:46 am

Then just show the parents of the found locations:

{foreach $node.object.assigned_nodes as $location}
<a href={$location.parent.url_alias|ezurl}>{$location.parent.name|wash}</a><br />
{/foreach}

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.