PDA

View Full Version : Dont display the promotion field if its similar to the description


IntroSites
26-01-09, 16:18
Posted for all in response to this thread (http://www.shopwindowforum.com/showthread.php?t=1143)

Dont display the "promotion" field if its the same as the "description"

Some merchants use the first sentence of the description for the promotion field, obviously this would stop you finding an exact match.

This checks if the first 40 characters of the promotion string are the same as the description string, if true the description only is displayed, if false you get promotion and description

SW V1

{$sProductDesc}
{if $sProductPromo[40] neq $sProductDesc[40]}
<br />
{$sProductPromo}
{/if}


This replaces
{$sProductDesc}
and
{$sProductPromo}
in product_display.tpl

SW V2

{$oProduct->sDescription}
{if $oProduct->sPromotion[40] neq $oProduct->sDescription[40]}
<br />
{$oProduct->sPromotion}
{/if}


This replaces
{$oProduct->sDescription}
and
{$oProduct->sPromotion}
in product_display.tpl

Hope that helps

amcho
26-01-09, 17:56
Thanks - cool bit of code,
I have also added the following to product_display_list.tpl (Version 1)
to get rid of the duplication in the product listings:

<p>{$oProduct->sProductPromo|truncate:#productDescMax#}</p>
{if $oProduct->sProductPromo[40] neq $oProduct->sProductDescription[40]}
<p>{$oProduct->sProductDescription|truncate:#productDescMax#}</p>
{/if}



This replaces:


<p>{$oProduct->sProductPromo|truncate:#productDescMax#}</p>
<p>{$oProduct->sProductDescription|truncate:#productDescMax#}</p>

Iarna
27-01-09, 00:12
Many Thanks