Jump to content

Product feature names as images [Solved]


blackflow

Recommended Posts

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 by blackflow (see edit history)
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

<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 by blackflow (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...