我正在尝试让Shop-Script Free by Webasyst在2个不同的网站上显示相同的购物车。我只想使用一个管理部分。
我可以获得类别,产品名称,产品数量,价格和布局,以正确显示在两个网站,但我不能让产品图片显示在第二个网站(他们显示在‘主’网站)。
我需要帮助的代码在$product_info7和$product_info5的if语句中。它们返回为false (0),并且不显示。
{if $product_info[7]}
<a href="index.php?productID={$product_info[11]}">
<img src="products_pictures/{$product_info[7]}" alt="{$product_info[1]|replace:'"':'& quot;'}" border=0 /><br />
{$smarty.const.MORE_INFO_ON_PRODUCT}
</a>
{else}
{if $product_info[5]}
<a href="index.php?productID={$product_info[11]}">
<img src="products_pictures/{$product_info[5]}" alt="{$product_info[1]|replace:'"':'& quot;'}" border=0 />
{$smarty.const.MORE_INFO_ON_PRODUCT}
</a>
{/if}
{/if}我试过{if $product_info[7] ne ''}和{if $product_info[7] ne NULL}
如有任何想法或帮助,我们将不胜感激。
发布于 2009-10-28 03:42:36
我非常确定在使用Smarty时,您必须使用isset来检查空值。所以你可以试试这个:
{if isset($product_info[5]) && $product_info[5] != ""}发布于 2009-10-28 03:44:51
我认为在smarty中,你必须使用点符号来索引数组。所以试试这个:
{if $product_info.7}
<a href="index.php?productID={$product_info.11}">
<img src="products_pictures/{$product_info.7}" alt="{$product_info.1|replace:'"':'& quot;'}" border=0 /><br />
{$smarty.const.MORE_INFO_ON_PRODUCT}
</a>
{else}
{if $product_info.5}
<a href="index.php?productID={$product_info.11}">
<img src="products_pictures/{$product_info.5}" alt="{$product_info.1|replace:'"':'& quot;'}" border=0 />
{$smarty.const.MORE_INFO_ON_PRODUCT}
</a>
{/if}
{/if}然而,我承认我没有尝试过你正在做的事情。不过,我建议使用关联数组,而不是数字索引数组。按照Smarty的设计方式,如果您的索引被命名,它会工作得更好。
https://stackoverflow.com/questions/1633071
复制相似问题