jarv
04-13-2012, 04:44 PM
hi,
On my Products-List page I have an IF condition stating IF $products.legend == 'bottle' THEN set image size based on that legend, see below:
{foreach from=$products item=product name=products}
<li>
{if $product.legend == 'bottle'}
<a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'bottle')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($bottleSize)} width="{$bottleSize.width}" height="{$bottleSize.height}"{/if} /></a>
{else}
<a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'clothing')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($clothingSize)} width="{$clothingSize.width}" height="{$clothingSize.height}"{/if} /></a>
{/if}
<h4>{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</h4>
<h6>{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}</h6>
<h6>{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}{/if}</h6>
<h6>{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}{/if}</h6>
{/if}
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
{if ($product.allow_oosp || $product.quantity > 0)}
<a class="buttonsmall" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart.php')}?add&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}" title="{l s='Add to Basket'}">{l s='Add to Basket'}</a>
{else}
<span class="buttonsmall">{l s='Add to cart'}</span>
{/if}
{/if}
</li>
{/foreach}
The above code works fine! Although, I'd like to do the same for the related products on the Product page:
{foreach from=$categoryProducts item='categoryProduct' name=categoryProduct}
<li {if count($categoryProducts) < 6}style="width: {math equation="width / nbImages" width=94 nbImages=$categoryProducts|@count}%"{/if}>
{if $categoryProducts.legend == 'bottle'}
<a href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}"><img src="{$link->getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'bottle')}" alt="{$categoryProduct.name|htmlspecialchars}" {if isset($bottleSize)} width="{$bottleSize.width}" height="{$bottleSize.height}"{/if} /></a><br/>
{else}
<a href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}"><img src="{$link->getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'clothing')}" alt="{$categoryProduct.name|htmlspecialchars}" {if isset($clothingSize)} width="{$clothingSize.width}" height="{$clothingSize.height}"{/if} /></a><br/>
{/if}
<a href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}">
{$categoryProduct.name|truncate:15:'...'|escape:'htmlall':'UTF-8'}
</a><br />
{if $ProdDisplayPrice AND $categoryProduct.show_price == 1 AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}
<span class="price_display">
<span class="price">{convertPrice price=$categoryProduct.displayed_price}</span>
</span><br />
{else}
<br />
{/if}
<a title="{l s='View' mod='productscategory'}" href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" class="button_small">{l s='View' mod='productscategory'}</a><br />
</li>
{/foreach}
The above code needs modifying , I need help here please!
thanks
On my Products-List page I have an IF condition stating IF $products.legend == 'bottle' THEN set image size based on that legend, see below:
{foreach from=$products item=product name=products}
<li>
{if $product.legend == 'bottle'}
<a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'bottle')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($bottleSize)} width="{$bottleSize.width}" height="{$bottleSize.height}"{/if} /></a>
{else}
<a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'clothing')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($clothingSize)} width="{$clothingSize.width}" height="{$clothingSize.height}"{/if} /></a>
{/if}
<h4>{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</h4>
<h6>{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}</h6>
<h6>{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}{/if}</h6>
<h6>{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}{/if}</h6>
{/if}
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
{if ($product.allow_oosp || $product.quantity > 0)}
<a class="buttonsmall" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart.php')}?add&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}" title="{l s='Add to Basket'}">{l s='Add to Basket'}</a>
{else}
<span class="buttonsmall">{l s='Add to cart'}</span>
{/if}
{/if}
</li>
{/foreach}
The above code works fine! Although, I'd like to do the same for the related products on the Product page:
{foreach from=$categoryProducts item='categoryProduct' name=categoryProduct}
<li {if count($categoryProducts) < 6}style="width: {math equation="width / nbImages" width=94 nbImages=$categoryProducts|@count}%"{/if}>
{if $categoryProducts.legend == 'bottle'}
<a href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}"><img src="{$link->getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'bottle')}" alt="{$categoryProduct.name|htmlspecialchars}" {if isset($bottleSize)} width="{$bottleSize.width}" height="{$bottleSize.height}"{/if} /></a><br/>
{else}
<a href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}"><img src="{$link->getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'clothing')}" alt="{$categoryProduct.name|htmlspecialchars}" {if isset($clothingSize)} width="{$clothingSize.width}" height="{$clothingSize.height}"{/if} /></a><br/>
{/if}
<a href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}">
{$categoryProduct.name|truncate:15:'...'|escape:'htmlall':'UTF-8'}
</a><br />
{if $ProdDisplayPrice AND $categoryProduct.show_price == 1 AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}
<span class="price_display">
<span class="price">{convertPrice price=$categoryProduct.displayed_price}</span>
</span><br />
{else}
<br />
{/if}
<a title="{l s='View' mod='productscategory'}" href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" class="button_small">{l s='View' mod='productscategory'}</a><br />
</li>
{/foreach}
The above code needs modifying , I need help here please!
thanks