Announcement

Collapse
No announcement yet.

Limit Best Sellers to X digits

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

    Limit Best Sellers to X digits

    Following on from the AUG guide on how to limit the number of words in a product description can you limit the number of letters returned in the ProductName on the best sellers list using PHP?

    David
    Cheers

    David
    Located in Edinburgh UK

    http://twitter.com/mcfinster

    #2
    I can not see why not...

    Simply look at the AUG code and as it is replacing the description variable and code, change that to the product title one in all occurences and it should do it just the same.... But the php code is for words and not number of characters, although someone should be able to work out a character version...

    Comment


      #3
      Yeah I did try that but got parse errors, presumably because of the php word code. Hopefully someone will know the correct code for characters!

      David
      Cheers

      David
      Located in Edinburgh UK

      http://twitter.com/mcfinster

      Comment


        #4
        OK so a dig around and a quick learning of basic php and I have come up with this:-

        <actinic:block php="true" >
        $sShort = "";
        $sOriginal = "ProductName";

        if (strlen($sOriginal)>10)
        {
        $sShort = substr($sOriginal,0,10) . "...";
        }
        else
        {
        $sShort = $sOriginal;
        }
        echo $sShort;
        </actinic:block>

        Now it works if you simply type in some basic text into $sOriginal but as soon as you use the ProductName variable it returns a Parse Error. Any ideas anyone?

        David
        Cheers

        David
        Located in Edinburgh UK

        http://twitter.com/mcfinster

        Comment


          #5
          Bingo!

          Never had selectable=false on, working code below:-

          <actinic:block php="true" >
          $sShort = "";
          $sOriginal = "<actinic:variable encoding="perl" name="ProductName" selectable="false" />";

          if (strlen($sOriginal)>10)
          {
          $sShort = substr($sOriginal,0,10) . "...";
          }
          else
          {
          $sShort = $sOriginal;
          }
          echo $sShort;
          </actinic:block>

          So to implement you want to open the 'Standard Best Seller Item' layout and replace all the code in there with:-

          <actinic:variable name="ListIndex" />. <a href="<actinic:variable name="SearchCGIURL" />?PRODREF=<actinic:variable name="ProductReference" />&amp;NOLOGIN=1<actinic:block if="%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e">&amp;SHOP=<actinic:variable name="ShopID" /></actinic:block>"><actinic:block php="true" >
          $sShort = "";
          $sOriginal = "<actinic:variable encoding="perl" name="ProductName" selectable="false" />";

          if (strlen($sOriginal)>10)
          {
          $sShort = substr($sOriginal,0,10) . "...";
          }
          else
          {
          $sShort = $sOriginal;
          }
          echo $sShort;
          </actinic:block></a>

          Changing the numbers '10' to however many characters you want to display. I would imagine it can be used to control the character display in almost any layout you want.

          David
          Cheers

          David
          Located in Edinburgh UK

          http://twitter.com/mcfinster

          Comment

          Working...
          X