Pedro Pinto Posted October 9, 2015 Share Posted October 9, 2015 Hello, i'm would like to have icon/png image as product feature value and for that : in product.tpl, i added the line (that works) <img src="{img_dir}featureicon/{$feature.value}.png"/> but there is a problem. And IF there's NO icon for that feature value?? so i need to display the value himself. i tried: {assign var="icon" value="{$img_dir}feature-icons/{$feature.value}.png"} {if file_exists($icon)} <td><img src="{$img_dir}feature-icons/{$feature.value}.png"/></td> {else} <td>{$feature.value|escape:'html':'UTF-8'}</td> {/if} but without a chance, i got always the value even for those that have an icon/image. any idea? Thanks..... Link to comment Share on other sites More sharing options...
yaniv14 Posted October 10, 2015 Share Posted October 10, 2015 I am not 100% sure but I think your var assignment is wrong. Try something like that: {assign var="icon" value="`$img_dir`feature-icons/`$feature.value`.png"} Link to comment Share on other sites More sharing options...
Pedro Pinto Posted October 12, 2015 Author Share Posted October 12, 2015 unfortunately it did not work , I continue with the same problem. Link to comment Share on other sites More sharing options...
yaniv14 Posted October 12, 2015 Share Posted October 12, 2015 Can you try printing $icon after the assignment in the template to see what you get? Also on your first post you have the folder name different in both places (featureicon) and (feature-icons) check which one is the correct one Link to comment Share on other sites More sharing options...
dirtrider118 Posted March 6, 2020 Share Posted March 6, 2020 This code works in 1.6 - file: product.tpl: replace this {foreach from=$features item=feature} {if isset($feature.value)} <li><b>{$feature.name|escape:'html':'UTF-8'}:</b> {$feature.value|escape:'html':'UTF-8'}</li> {/if} {/foreach} With: {foreach from=$features item=feature} {if isset($feature.value)} {assign var="iconFeat" value="img/icons/{$feature.value}.jpg"} {if file_exists($iconFeat)} <td><img src="http://yourwebsite.com/img/icons/{$feature.value}.jpg"/></td> {else} <li><b>{$feature.name|escape:'html':'UTF-8'}:</b> {$feature.value|escape:'html':'UTF-8'}</li> {/if} {/if} {/foreach} Create a folder called "icons" inside your "img" folder within the root directory (outside the themes folder). Place all your icon images inside the new "icon" folder and make sure the image filename matches exactly the same as the product features value setup in the backend (do not include image extension ".jpg" within the feature value). Also, make sure none of your images or product feature values are the same for other features. 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