Forums / Setup & design / I can't catch the error

I can't catch the error

Author Message

Børge Warvik

Monday 30 January 2006 1:26:20 am

In a template I do this:

<div class="cbox">

<h3>Eksterne linker</h3>

{def $links=fetch('content', 'list', hash('parent_node_id', 84, 'sort_by', 'short_name', 'class_filter_type', 'include', 'class_filter_array', array('link')))}

<ul>
{foreach $links as $link}
<li><a href="{attribute_view_gui attribute=$link.object.data_map.url}">{attribute_view_gui attribute=$link.object.data_map.short_name}</a></li>
{/foreach}
</ul>
</div>

Everything is working fine, but my debug output gives me this error. The error is printed for each of the $link items of $links:

Error: eZTemplate @ design/nifab/override/templates/frontpage_full.tpl:13[13]
No such attribute for array(4): url
Choose one of following: name, short_name, description, location
Warning: eZTemplate:attribute_view_gui
Parameter attribute is not an object

What am I doing wrong?

Børge Warvik

Monday 30 January 2006 1:44:30 am

Figured this one out eventually :)

David Boman

Monday 30 January 2006 1:50:13 am

Can you give us some hints? I have a lot of these and I'm not really sure how to start debugging them...

Børge Warvik

Monday 30 January 2006 2:14:11 am

I was wrong! My code didn't work at all, it just looked like it did. It turned out that my $node didn't have a url attribute.

So printing the link like this:

<a href="{attribute_view_gui attribute=$link.object.data_map.url}"> {attribute_view_gui attribute=$link.object.data_map.name} </a>

Will give you links on the page, but if you view the the source you'll see:

<a href="">[name of link]</a>

It turns out that you need to use the attribute location, like this:

{attribute_view_gui attribute=$link.object.data_map.location}

That will give you all you need including wrapping the link in the a tag for you!

Hope that answers it