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.

eZ debug

Timing: Jan 31 2025 04:15:24
Script start
Timing: Jan 31 2025 04:15:24
Module start 'layout'
Timing: Jan 31 2025 04:15:24
Module start 'content'
Timing: Jan 31 2025 04:15:24
Module end 'content'
Timing: Jan 31 2025 04:15:24
Script end

Main resources:

Total runtime0.0138 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.3906151.2422
Module start 'layout' 0.00480.0021 739.632836.7109
Module start 'content' 0.00690.0057 776.343894.3438
Module end 'content' 0.01260.0012 870.687537.9922
Script end 0.0138  908.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002215.9617140.0002
Check MTime0.00107.1472140.0001
Mysql Total
Database connection0.00064.614210.0006
Mysqli_queries0.002215.642730.0007
Looping result0.00000.056910.0000
Template Total0.00107.310.0010
Template load0.00085.762610.0008
Template processing0.00021.489810.0002
Override
Cache load0.00053.608910.0005
General
dbfile0.002216.251480.0003
String conversion0.00000.050040.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