Search code examples
phpe-commercesmartyprestashop-1.6

Prestashop 1.6 / Thirtybees: how to call a feature to Product.tpl?


https://github.com/thirtybees/niara/blob/master/product.tpl#L552-L559 shows how all relevant features are called to the product template - product.tpl . This is the code:

{if !empty($features)}
{foreach from=$features item=feature}
   {if isset($feature.value)}
       {$feature.name|escape:'html':'UTF-8'}
       {$feature.value|escape:'html':'UTF-8'}
   {/if}
{/foreach}
{/if}

Does anyone know how I just call Feature id 33, named Colour ? My idea is that I could put some microformat schema codes round it, so search engines could know the colour. Maybe it's tricky and that's why I haven't seen anyone else do it, but any help is appreciated.


Solution

  • To do this, you need a test on the feature value:

    {if !empty($features)}
        {foreach from=$features item=feature}
            {if isset($feature.value)}
                {if $feature.id_feature == 33}
                    {$feature.name|escape:'html':'UTF-8'}
                    <span itemprop="color">{$feature.value|escape:'html':'UTF-8'}</span>
                {else}          
                    {$feature.name|escape:'html':'UTF-8'}
                    {$feature.value|escape:'html':'UTF-8'}
                {/if}
            {/if}      
        {/foreach}
    {/if}
    

    Regards