Forums / Setup & design / trouble with attributes

trouble with attributes

Author Message

Aleksandar Adam

Saturday 09 July 2005 4:01:35 pm

I have the following problem:

I have a line with "fetch" like this:

let children=fetch('content','tree',hash(parent_node_id,$node.node_id,limit,5, class_filter_type, 'exclude', class_filter_array, array(21,20,27,1,2)

then I would like to print "forum reply" attributes in the following lines:

section name=Child loop=$children
attribute_view_gui attribute=$Child:item.......
/section

I don't know what to write after the "$Child:item" to reach the following attributes of the "forum reply" class:
- the name of the "forum reply" object
- the author's name
- the date
so that i got something in style:

reply xxxx
Forum User, 6th june 2005

and if it is possible to klick on the reply and the read the whole text

I have tried everything what I could possibly think out and now I got a terrbile headache, any answer will be appreciated

Eivind Marienborg

Sunday 10 July 2005 1:28:37 am

Hi Aleksander :)

To see all attributes of an object, use the attribute(show) function, like this:

{$Child:item|attribute(show)}

If you for example want to access the authors name, it's probably shown like this

> Item
>> Object
>>> owner
>>>> Name

To use it in a template you use

{$Child:item.object.owner.name}

Look for the other attributes, and use it in the same way. If you need to see further down in the attribute tree, adjust the depth like this:

{$Child:item|attribute(show,5)}

Where 5 is the depth in this example. But in my experience, going deeper than 4 usually crashes eZ.

Hope this helps :)

Aleksandar Adam

Sunday 10 July 2005 1:35:25 am

Thanks it works, :-)

but now I am little bit curious, why did't it work with:

attribute_view_gui attribute=$Child:item.object...

what is the difference?

Eivind Marienborg

Sunday 10 July 2005 2:09:00 am

What's the full attribute you specified in "Child:item.object..."?

The attribute_view_gui displays ez-attributes, but if you for example use $Child:item.object.owner.name, that's simply a string (and not an ez-attribute), so it doesn't need to be passed throught the attribute_view_gui to be proparly displayed.

Eivind Marienborg

Sunday 10 July 2005 2:13:49 am

This is the section-code I use to display the last replies in my eZ-forum. It displays the title of the thread, with date and author on mouseover, and the number of replies and parent (usually a forum).

If you're gonna use it, notice that I haven't used namespaces in it, so you have to adjust this/your code a bit.

{section loop=$:topics}

<li><div class="name"><a href={$:item.url_alias|ezurl} title="Last reply: {$:item.modified_subnode|l10n(datetime)} by {$:item.object.owner.name}">{$:item.name}</a>
</div>
<div class="reply">{$:item.children_count} replies</div>
<div class="parent"><a href={$:item.parent.url_alias}>{$:item.parent.name}</a>
</div></li>

{/section}

Aleksandar Adam

Sunday 10 July 2005 3:58:04 am

I have used:

attribute_view_gui attribute=$Child:item.object.name

attribute=attribute_view_gui attribute=$Child:item.object.data_map.name

and many other wrong combinations, so i wonder what is the correct way.

Eivind Marienborg

Sunday 10 July 2005 9:47:10 am

You do this:

{$Child:item.name}

No attribute_view_gui at all.

:)