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.

eZ debug

Timing: Jan 19 2025 00:11:12
Script start
Timing: Jan 19 2025 00:11:12
Module start 'layout'
Timing: Jan 19 2025 00:11:12
Module start 'content'
Timing: Jan 19 2025 00:11:12
Module end 'content'
Timing: Jan 19 2025 00:11:12
Script end

Main resources:

Total runtime0.0189 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 587.8047152.6094
Module start 'layout' 0.00770.0032 740.414139.4141
Module start 'content' 0.01090.0056 779.828189.3984
Module end 'content' 0.01650.0023 869.226634.3047
Script end 0.0189  903.5313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002814.5772140.0002
Check MTime0.00126.1512140.0001
Mysql Total
Database connection0.00094.669510.0009
Mysqli_queries0.004121.445930.0014
Looping result0.00000.089510.0000
Template Total0.001910.010.0019
Template load0.00115.881310.0011
Template processing0.00084.051610.0008
Override
Cache load0.00084.300010.0008
General
dbfile0.00115.612780.0001
String conversion0.00000.049240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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