Forums / Developer / Image link question

Image link question

Author Message

Niklas Gunnäs

Thursday 16 March 2006 12:23:23 am

I would like to fetch a value and use it to set with image to use. Is there a way to do this?

Exemple

<img src={"{$current_node.object.data_map.projektansvarig.contentclass_attribute.name|wash}.gif"|ezimage} alt="projectimage" align="absmiddle">

Kristof Coomans

Thursday 16 March 2006 2:18:01 am

This will work better:

<img src={concat($current_node.object.data_map.projektansvarig.contentclass_attribute.name|wash, ".gif")|ezimage} alt="projectimage" align="absmiddle">

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Niklas Gunnäs

Thursday 16 March 2006 4:45:45 am

Thanks a million, Kristof

Need some more help :-(

I use it in the following way

<img src={concat(status, $Child:item.object.data_map.status.contentclass_attribute.content.options[$:item.object.data_map.status.content[0]].name, ".gif")|ezimage} alt="projectimage" align="absmiddle"> {attribute_view_gui attribute=$Child:item.object.data_map.status}%

For value 00, 10 and 20 it works correct but from 30 to 100 it makes a jump to next value for exampel it will show image "status40.gif" and shows 30% next to the image, instead of status30.gif and 30%. Value 100 will not show at all.

Betsy Gamrat

Thursday 16 March 2006 5:47:42 am

I would check the class definition to see if one of the values is missing.

Niklas Gunnäs

Thursday 16 March 2006 5:59:16 am

Have checked a hundred times :-)

Gets the same error on diffrent classes

Kristof Coomans

Thursday 16 March 2006 7:12:33 am

In PHP, the class attribute options of the selection datatype are structured like this:

array(
    array( 'id' => 1, 'name' => 10 ),
    array( 'id' => 2, 'name' => 20 )
)

Now if you ever added options in an incorrect order and later corrected your mistake by reordering them, you can get this:

array(
    array( 'id' => 1, 'name' => 10 ),
    array( 'id' => 2, 'name' => 20 ),
    array( 'id' => 4, 'name' => 30 ),
    array( 'id' => 3, 'name' => 40 ),
)

So I think this should do it:

{def $statusAttrib=$Child:item.object.data_map.status}
{foreach $statusAttrib.contentclass_attribute.content.options as $classAttribOption}
{if $classAttribOption.id|eq(statusAttrib.content[0])}
<img src={concat(status, $classAttribOption.name, ".gif")|ezimage} alt="projectimage" align="absmiddle">&nbsp;{attribute_view_gui attribute=$statusAttrib}%
{/if}
{/foreach}
{undef $statusAttrib}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Kristof Coomans

Monday 20 March 2006 12:02:01 pm

There was a little error in my previous template code. This should work:

{def $statusAttrib=$Child:item.object.data_map.status}
{foreach $statusAttrib.contentclass_attribute.content.options as $classAttribOption}
{if $classAttribOption.id|eq($statusAttrib.content[0])}
<img src={concat(status, $classAttribOption.name, ".gif")|ezimage} alt="projectimage" align="absmiddle">&nbsp;{$classAttribOption.name}%
{/if}
{/foreach}
{undef $statusAttrib}

And if your attribute is a multiple selection (works for single selection too):

{def $statusAttrib=$Child:item.object.data_map.status}
{foreach $statusAttrib.contentclass_attribute.content.options as $classAttribOption}
{if $statusAttrib.content|contains($classAttribOption.id)}
<img src={concat(status, $classAttribOption.name, ".gif")|ezimage} alt="projectimage" align="absmiddle">&nbsp;{$classAttribOption.name}%
{/if}
{/foreach}
{undef $statusAttrib}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Niklas Gunnäs

Monday 20 March 2006 3:20:23 pm

It works, It works :-)

Dont know how to thank you.

If you ever comes to Stockholm I will buy you a very, very large beer :-)

Niklas
www.infos.se

eZ debug

Timing: Jan 18 2025 21:07:06
Script start
Timing: Jan 18 2025 21:07:06
Module start 'content'
Timing: Jan 18 2025 21:07:06
Module end 'content'
Timing: Jan 18 2025 21:07:06
Script end

Main resources:

Total runtime0.1697 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 587.6094180.8438
Module start 'content' 0.00620.0043 768.4531105.9609
Module end 'content' 0.01050.1590 874.4141533.8594
Script end 0.1695  1,408.2734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.2051200.0002
Check MTime0.00140.8052200.0001
Mysql Total
Database connection0.00090.504410.0009
Mysqli_queries0.120170.80161410.0009
Looping result0.00140.85301390.0000
Template Total0.158793.510.1587
Template load0.00080.472110.0008
Template processing0.157993.047310.1579
Override
Cache load0.00060.354810.0006
Sytem overhead
Fetch class attribute can translate value0.00100.601610.0010
XML
Image XML parsing0.00040.258110.0004
General
dbfile0.00573.3808200.0003
String conversion0.00000.003730.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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