Get image attribute without triggering view's image alias.

Author Message

paul bolger

Saturday 03 March 2007 10:37:34 pm

Our site has a front page has two template includes which pull three articles each from another place in the system - we are using multiple locations to select the articles, they are given a second location in a hidden node and two templates included in the front page pagelayout then pull the first three articles by priority.

Each item pulled gets the title of the article, a shortened version of the short description (with a link to the main article) and an attribute related image. The text bits work fine, but the images get processed throught the following templates:

design/news_site/templates/ezobjectrelation.tpl
design/news_site/templates/image.tpl
design/news_site/templates/ezimage.tpl

- and image.tpl sets (and overrides) the image alias. The problem is that the two inclusions need different image aliases. How do I call the image and get it to take the image alias in the foreach statement?

BTW - I'm not sure of the validity of that h2 in the dd, but that can be addressed later, and yes, the title in the link is still a work in progress...

{def $highlights=fetch( 'content', 'list',
hash( 'parent_node_id', '434',
'sort_by', 'priority',
'limit', '3'
 ))}
{foreach $highlights as $highlight}
<dl class="smallhighlight">
<dt style="width:{$highlight.object.data_map.image.content[smallhighlights].width}px">
{attribute_view_gui attribute=$highlight.data_map.image image_class=smallhighlights}</dt>
<dd><h2>{attribute_view_gui attribute=$highlight.data_map.title}</h2>
{strip_tags( $highlight.data_map.intro.value.output.output_text ) | wash | shorten(50, '...', right)} 
<a href={$highlight.url} title="more about {$highlight.data_map.title}">more&#187;</a></dd>
</dl>

regards
Paul Bolger

<i>// please use

 tag for code snippets</i>

Paul Bolger

Ɓukasz Serwatka

Tuesday 06 March 2007 12:57:53 am

Hi,

If I understand you correct, you can solve it by passing size variable to included template

{include uri="design:mytpl.tpl" image_size=small}

then in template use

{$highlight.object.data_map.image.content[$image_size].width}

of course you need to change every tpl code where you use image alias.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

paul bolger

Tuesday 06 March 2007 4:50:35 pm

Hi Lukasz

Sorry, I mustn't be making myself clear.

The problem is that the two templates, 'bighighlights' and 'smallhighlights', are supposed to give their images different image aliases. The width attribute on the dt is also a problem, but I'll worry about that when I've got the images appearing correctly.

The problem is the line

{attribute_view_gui attribute=$highlight.data_map.image image_class=smallhighlights}

results in whatever image alias is set in the image.tpl template.

I've tried the

{$highlight.object.data_map.image.content[smallhighlights].full_path}

method

but that doesn't seem to work.

From what I understand I either need to call the attribute directly, bypassing the view templates, or override the view (twice, once for each bighighlights, once for small highlights) later on. But I'm not sure how to do that.

paul b

Paul Bolger

paul bolger

Thursday 08 March 2007 9:56:14 pm

Fixed!

Although it was my co-developer, Venji, who found the solution.

The syntax is

{attribute_view_gui attribute=$node.object.data_map.image.content.data_map.image image_class=image_alias}

Which I certainly wouldn't have guessed.

There's a reference to it here:

http://ez.no/community/articles/building_a_custom_template_for_a_news_portal/user_defined_display_templates

Paul Bolger

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.