Announcement

Collapse
No announcement yet.

Only Displaying the First Ten Words of the Full Description

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Only Displaying the First Ten Words of the Full Description

    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 ...

    #2
    Hi Dave,

    This code worked for me when applying it to my Mini Best Seller Layout:

    <actinic:block php="true" >
    $sShort = "";
    $nCount = 0;
    $sOriginal = '<actinic:variable encoding="perl" name="ProductName" selectable="false" />';
    foreach(explode(" ", $sOriginal) as $sWord)
    {
    if ($nCount > 6)
    {
    $sShort .= "...";
    break;
    }
    $sShort .= $sWord . " ";
    $nCount++;
    }
    echo $sShort;
    </actinic:block>
    Regards,

    Toby Blanchard

    Comment

    Working...
    X