Tabber prompts appear on New Products and Best Sellers.

Tabbed Product and Fragment Descriptions.
Post Reply
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Tabber prompts appear on New Products and Best Sellers.

Post by norman »

If you include Tabber products in these lists then you may get a description like:

{Summary}Summary text.{Details}Detailed description{Etc}.....

Here are two ways to overcome this.

1) To get a description like:

Summary
Summary text.
Details
Detailed description
Etc
.....

We need to replace the { and } with newlines via the following.
In your New Products and Best Sellers layouts replace

Code: Select all

<actinic:variable name="ProductDescription" />
with

Code: Select all

<actinic:block php="true">
$pd = <<<ENDOFCODE
<actinic:variable name="ProductDescription" />
ENDOFCODE;
$pd = str_replace('&#123;', '<br/><b>', $pd);		// replace all { with <br/> and make bold
$pd = str_replace('&#125;', '<br/></b>', $pd);		// replace all } with <br/> and end bold
echo $pd;
</actinic:block>
2) To lose the tab names completely and get a description like:

Summary text.
Detailed description
.....

We replace

Code: Select all

<actinic:variable name="ProductDescription" />
with

Code: Select all

<actinic:block php="true">
$pd = <<<ENDOFCODE
<actinic:variable name="ProductDescription" />
ENDOFCODE;
$pd = preg_replace('/&#123;.*?&#125;/', '<br/>', $pd);		// replace all {...} with <br/>
echo $pd;
</actinic:block>
3) And here is how to combine (2) with the Advanced Guide article "Display Only First Ten Words...".

We replace

Code: Select all

<actinic:variable name="ProductDescription" />
with

Code: Select all

<actinic:block php="true" >
$sShort = "";
$nCount = 0;
$sOriginal = <<<ENDOFCODE
<actinic:variable name="ProductDescription" />
ENDOFCODE;
$sOriginal = preg_replace('/&#123;.*?&#125;/', '', $sOriginal);      // remove all {...}
foreach(explode(" ", $sOriginal) as $sWord)
	{
	if ($nCount > 10)
		{
		$sShort .= "...";
		break;
		}
	$sShort .= $sWord . " ";
	$nCount++;
	}
echo $sShort;
</actinic:block>
Note that when pasting this code into layouts, the line:

ENDOFCODE;

must not be indented in any way or you will get PHP errors.
Norman
wickedwildweb
Posts: 1
Joined: Wed Feb 22, 2012 12:14 am

Re: Tabber prompts appear on New Products and Best Sellers.

Post by wickedwildweb »

Worked perfectly thanks Norman.

Worth noting, whilst following the 3rd example, if you want to change number of chars displayed then you simply change the numerical ten in the code below to whatever value you deem best

if ($nCount > 10)
Post Reply