I am kind of new on PrestaShop and I would like to learn more about Smarty templates and .tpl files.
I have a problem with changing {$image.bySize.home_default.url}
inside products.tpl
I'll try to explain my situation:
.
.
Category filter
Product from category
themes\footwear\templates\catalog_partials\miniatures\product.tpl
/*
where can I create/modify/add
{$image.bySize.home_default.url}
*/
<!--
themes\footwear\templates\catalog\_partials\miniatures\product.tpl
-->
<div >
{block name='product_thumbnail'}
<a href="{$product.url}" >
{foreach name="thumbnails" from=$product.images item=image}
{if $smarty.foreach.thumbnails.iteration == 2}
<img
src="{$image.bySize.home_default.url}" <!-- ?? -->
alt="{$image.legend}"
>
{/if}
{/foreach}
{if $product.cover}
<img
src="{$product.cover.bySize.home_default.url}"
alt="{$product.cover.legend}"
data-full-size-image-url = "{$product.cover.large.url}"
itemprop="image"
>
{else}
<img
src="{$urls.no_picture_image.bySize.home_default.url}"
>
{/if}
</a>
{/block}
{block name='product_flags'}
<ul >
{if $product.has_discount}
{if $product.discount_type === 'percentage'}
<li >{$product.discount_percentage}</li>
{elseif $product.discount_type === 'amount'}
<li >{$product.discount_amount_to_display}</li>
{/if}
{/if}
{foreach from=$product.flags item=flag}
<li >{$flag.label}</li>
{/foreach}
</ul>
{/block}
</div>
What I'd like to change
When I put a filter (Black/White) I still see my default color cloth and It's very messy. When I filter all white cloths, I would like to see all white cloths and not blue, red, yellow, green that also is available in black or white.
I tought that I could change the {$image.bySize.home_default.url} in the product.tpl when the url changed:
domain.com/3-clothes ?q=Color-White
I can't find any .php file that is related to {$image.bySize.home_default.url} and I can't write <?php ?>
inside .tpl files.
{$image.bySize.home_default.url} = /1087-home_default/bari.jpg (black)
if ($_GET['q']=Color-white
/1151-home_default/bari.jpg (white)
Can someone help me? or explain me how this Smarty templates works?
CodePudding user response:
I also want to share that the. Tpl files are Smarty Template Engine. It's a a kind of HTML PHP mixture.
The php $_GET can be used in Smarty with {$smarty.get.key}
I hope it helped you a bit.