如何显示产品的第二张图片和最后一张图片? PrestaShop

时间:2019-06-13 23:20:51

标签: image product prestashop-1.7

对于某些产品,我想在悬停时显示第二个产品图像。 还有最后一张特定类别的图片。

我试图这样做,但是我使用的是1.7.5.1版

<a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}">
    {assign var='productimg' value=Tools::getProductsImgs($product.id_product)}                         
    {if isset($productimg[0]) && isset($productimg[1])}
        <img class="img_0"  src="{$link->getImageLink($product.link_rewrite,$product.id_product|cat:"-"|cat:$productimg[0].id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />
        <img class="img_1" src="{$link->getImageLink($product.link_rewrite,$product.id_product|cat:"-"|cat:$productimg[1].id_image, 'home_default')}"alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />                           
    {else}
        <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html'}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />                   
    {/if}
    {if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if}
</a>

刷新页面时,我只会看到标题为“新收藏集”的部分已打开且未关闭。没什么,所有页面都是空的。

1 个答案:

答案 0 :(得分:0)

“工具:: getProductsImgs”不存在。

尝试一下:

{assign var='productimg' value=Image::getImages($language.id, $product.id)}                         
{if isset($productimg[0]) && isset($productimg[1])}
    <img class="img_0"  src="{$link->getImageLink($product.link_rewrite,$product.id_product|cat:"-"|cat:$productimg[0].id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />
    <img class="img_1" src="{$link->getImageLink($product.link_rewrite,$product.id_product|cat:"-"|cat:$productimg[1].id_image, 'home_default')}"alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />
{else}
    <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html'}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />                   
{/if}

致谢