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

    I just tried to add the 'Only Displaying the First Ten Words of the Full Description' to one of our sites to test it to sea what it dose and it will not work I have PHP5 installed on my pc and all I get is the following error in the main actinic catalog..

    Only Displaying the First Ten Words of the Full Description

    I know a bit of PHP so I tried removed the line with the ProductDescription in and guess what it work...

    I have a look at fxing the script but not holding out mutch hope!

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

    #2
    That code works fine for me (but single quotes get displayed as \').

    You don't seem to have posted the error you get.

    Also you don't need PHP installed on your PC. A copy is embedded in the Actinic application and that will be the one that gets used.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Ahah! I see a problem. The encoding="perl" fragment tells actinic to return a string that's safe for putting into PHP within single quotes. If you have a double-quote( " ) in your product description that will break the patch. Use this instead and all should be well.
      Code:
      <actinic:block php="true" >
      $sShort = "";
      $nCount = 0;
      $sOriginal = '<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />'; 
      foreach(explode(" ", $sOriginal) as $sWord)
      	{
      	if ($nCount > 10)
      		{
      		$sShort .= "...";
      		break;
      		}
      	$sShort .= $sWord . " ";
      	$nCount++;
      	}
      echo $sShort;
      </actinic:block>
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Thanks Norman I give that a try when I am back in the office in the morning.

        Comment

        Working...
        X