Hi all,
I'm using an adapted version of 'Only Displaying the First Ten Words of the Full Description', but instead of using it for product description, I want to use it for product name.
Also, I only want the fist 7 words.
It doesn't seem to work, and still shows the full product name without any "...". Does anyone know where I might be going wrong?
<actinic:block php="true" >
$sShort = "";
$nCount = 0;
$sOriginal = '<actinic:variable name="ProductName" />';
foreach(explode(" ", $sOriginal) as $sWord)
{
if ($nCount > 7)
{
$sShort .= "...";
break;
}
$sShort .= $sWord . " ";
$nCount++;
}
echo $sShort;
</actinic:block>
Cheers guys ...
I'm using an adapted version of 'Only Displaying the First Ten Words of the Full Description', but instead of using it for product description, I want to use it for product name.
Also, I only want the fist 7 words.
It doesn't seem to work, and still shows the full product name without any "...". Does anyone know where I might be going wrong?
<actinic:block php="true" >
$sShort = "";
$nCount = 0;
$sOriginal = '<actinic:variable name="ProductName" />';
foreach(explode(" ", $sOriginal) as $sWord)
{
if ($nCount > 7)
{
$sShort .= "...";
break;
}
$sShort .= $sWord . " ";
$nCount++;
}
echo $sShort;
</actinic:block>
Cheers guys ...
Comment