How to list a object relation list

Author Message

Werner Klausen

Monday 02 May 2005 12:36:46 am

Hi, I've browsed the forum now for quite a while, but none of the other posts about this topic seems to do the trick, but I'm sure the answer is quite simple :)

I have a custommade class called <i>mainmenu</i> (node 102). This have the attributes <i>name</i> and <i>elements</i>. The attribute <i>elements</i> is a object relation list.

Now what i want is to somehow fetch the content of <i>elements</i> and display it to screen (and use it as a menu).

Now I think I've understanded that attribute_view_gui should maybe be used, but I just can't seem to get it to work.

Thanks :)

ADDON: I would like to go through the object list using a loop, as I want to put one and one list into a <li> element.

Because I can!

Felix Laate

Monday 02 May 2005 12:59:29 am

Hi Werner!

I've done this with:

{*related is object relation list*}
{attribute_view_gui attribute=$node.object.data_map.related}

(in the full override for the class in question)

If you want to do a manual loop, you could perhaps do this:

{section name=myLoop loop=$node.object.data_map.related}
<li>$myLoop:item.blablabla</li>
{/section}

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Werner Klausen

Monday 02 May 2005 1:19:05 am

Thanks for the reply Felix!

I probably should have stated that I'm very new to eZ, but I understood that I needed more code than that. :)

This is now what I got semi working:

<ul>
{let attribute=fetch( 'content', 'node', hash( 'node_id', 102 ))}
{*elementer is object relation list*}
{attribute_view_gui attribute=$attribute.object.data_map.elementer}
{/let}
</ul>

For some reston I had to change <i>node</i> to <i>attribute </i> in $node.object.data_map.elementer to get it to list anything. However, I did not get the loop to work. And in addition it's listing out all the childnodes that each object-relation got.

eZ template language is very confusing atm :)

Because I can!

Werner Klausen

Monday 02 May 2005 3:37:56 am

Ok, now I got it to list one and one item of the object relation list, just thought I'd show how in case others might find it useful:

<ul>
{let menu=fetch( 'content', 'node', hash( 'node_id', 102 )) }
{section var=Relations loop=$menu.object.data_map.elementer.content.relation_list}
<li>
{content_view_gui view=text content_object=fetch( content, object,
hash( object_id, $Relations.item.contentobject_id ))}
</li>
{/section}
{/let}
</ul>

Now all I need is to make links of these somehow so that they link to the actual object that they are :)

Because I can!

Werner Klausen

Monday 02 May 2005 3:49:32 am

view=text_linked

:) I Suppose this thread is now ended for my part.

Because I can!

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 18:33:33
Script start
Timing: Jan 18 2025 18:33:33
Module start 'layout'
Timing: Jan 18 2025 18:33:33
Module start 'content'
Timing: Jan 18 2025 18:33:33
Module end 'content'
Timing: Jan 18 2025 18:33:33
Script end

Main resources:

Total runtime0.0175 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 587.9219152.6250
Module start 'layout' 0.00730.0026 740.546939.4609
Module start 'content' 0.00990.0056 780.007893.3672
Module end 'content' 0.01550.0020 873.375038.3047
Script end 0.0175  911.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002815.7773140.0002
Check MTime0.00127.0115140.0001
Mysql Total
Database connection0.00147.804210.0014
Mysqli_queries0.002313.117330.0008
Looping result0.00000.080410.0000
Template Total0.00169.010.0016
Template load0.00084.723410.0008
Template processing0.00074.244010.0007
Override
Cache load0.00053.125810.0005
General
dbfile0.00031.584080.0000
String conversion0.00000.057240.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