开发者

PHP/Smarty Shop Script issue

I'm trying to get Shop-Script Free by Webasyst to display the same shopping cart on 2 different websites. I want to only use one admin section.

I can get the categories, product names, product counts, prices and layout to display properly on both websites but I can't get the product images to show up on the second website (they display fine on the 'main' website).

The code I need help with is in the if statements for the $product_info[7] and $product_info[5]. They are coming back as false (0) and are not displaying.

{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}

I've tried {if $product_info[7] ne ''} and {if $product_info[7] ne NULL}

Any thought开发者_运维知识库s or help would be greatly appreciated.


I'm pretty sure that with Smarty you have to use isset to check for a null value. So try this out:

{if isset($product_info[5]) && $product_info[5] != ""}


I think you have to use dot-notation to index into arrays in smarty. So try this:

{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}

However I admit I have not tried it the way you are doing it. I would recommend using an associative array though, instead of a numerically indexed one. The way Smarty is designed, it works much better if your indexes are named.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜