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.