blackflow Posted April 16, 2015 Share Posted April 16, 2015 (edited) As in the title I want to add images instead of names in the feature section of my products I've tried to wright something but it's not working :/ Any ideas what I am doing wrong? {foreach from=$features item=feature} <tr class="{cycle values="odd,even"}"> {if isset($feature.name) == 'feature1'} <img src="img/cashand.png"> {elseif $feature.name == 'feature2'} <img src="img/smallCart.png"> {else} <td>{$feature.name|escape:'html':'UTF-8'}</td> {/if} <td>{$feature.value|escape:'html':'UTF-8'}</td> </tr> {/foreach} It's a part of product.tpl running on presta 1.6.9 Edited April 26, 2015 by blackflow (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted April 18, 2015 Share Posted April 18, 2015 First of all, this one looks strange to me... {if isset($feature.name) == 'feature1'} At least I've never seen it. Expect it to be: {if isset($feature.name) && $feature.name eq 'feature1' } If $features is not an array of objects, but a SQL query result (like after the getFeatures() function I believe) , you should probably reach the name like this: $feature['name'] , as it is then an array (of arrays) So then you get {if isset($feature['name]) && $feature['name] eq 'feature1' } and $feature['value'] See if this helps. It still problems, see if you get any error. (Maybe temporarily turn on debug mode) My 2 cents, pascal 1 Link to comment Share on other sites More sharing options...
blackflow Posted April 26, 2015 Author Share Posted April 26, 2015 (edited) <section class="page-product-box"> <h3 class="page-product-heading">{l s='Data sheet'}</h3> <table class="table-data-sheet"> {foreach from=$features item=feature} <tr class="{cycle values="odd,even"}"> {if isset($feature.name) && $feature.name == 'something1' } <td>insert_image_here</td> <td>{$feature.value|escape:'html':'UTF-8'}</td> {/if} </tr> <tr class="{cycle values="odd,even"}"> {if isset($feature.name) && $feature.name == 'something2' } <td>insert_image_here</td> <td>{$feature.value|escape:'html':'UTF-8'}</td> {/if} </tr> {/foreach} </table> </section> For future reference, this works. It's probably not very efficient to hard code it, but if you need images instead of feature names, this is one solution . Thx to Pascal! Edited April 26, 2015 by blackflow (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now