Forums / Setup & design / Get image attribute without triggering view's image alias.

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

eZ debug

Timing: Jan 18 2025 15:51:43
Script start
Timing: Jan 18 2025 15:51:43
Module start 'content'
Timing: Jan 18 2025 15:51:44
Module end 'content'
Timing: Jan 18 2025 15:51:44
Script end

Main resources:

Total runtime1.0341 sec
Peak memory usage4,096.0000 KB
Database Queries197

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 589.1016180.7969
Module start 'content' 0.00580.8612 769.8984574.1641
Module end 'content' 0.86700.1671 1,344.0625336.7422
Script end 1.0341  1,680.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00460.4452210.0002
Check MTime0.00150.1472210.0001
Mysql Total
Database connection0.00090.089810.0009
Mysqli_queries0.950491.89831970.0048
Looping result0.00230.22551950.0000
Template Total1.007397.420.5037
Template load0.00250.242320.0013
Template processing1.004897.163420.5024
Template load and register function0.00010.007510.0001
states
state_id_array0.00070.068110.0007
state_identifier_array0.00230.223120.0012
Override
Cache load0.00200.1958470.0000
Sytem overhead
Fetch class attribute can translate value0.00260.247330.0009
Fetch class attribute name0.00190.185160.0003
XML
Image XML parsing0.00120.120430.0004
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.00240.2326350.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs