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

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 19 2025 00:07:08
Script start
Timing: Jan 19 2025 00:07:08
Module start 'layout'
Timing: Jan 19 2025 00:07:08
Module start 'content'
Timing: Jan 19 2025 00:07:08
Module end 'content'
Timing: Jan 19 2025 00:07:08
Script end

Main resources:

Total runtime0.0240 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.0093 587.8203152.6094
Module start 'layout' 0.00930.0050 740.429739.4141
Module start 'content' 0.01430.0071 779.8438101.4297
Module end 'content' 0.02140.0026 881.273442.3047
Script end 0.0240  923.5781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002811.5998140.0002
Check MTime0.00114.5726140.0001
Mysql Total
Database connection0.003414.251410.0034
Mysqli_queries0.004016.716030.0013
Looping result0.00000.104410.0000
Template Total0.00229.110.0022
Template load0.00125.176810.0012
Template processing0.00093.851010.0009
Override
Cache load0.00083.484310.0008
General
dbfile0.00156.399280.0002
String conversion0.00000.032840.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