Announcement

Collapse
No announcement yet.

embedded HTML in product descriptions - using in section links

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

    embedded HTML in product descriptions - using in section links

    Hello,

    I am converting my site to SPP, with a section links page which includes an image, add to basket button, and the first 15 words of the description.

    For some products, I have embedded HTML at the beginning of the product descriptions, and the HTML tags are showing in the section link. Is there any way to get the section link to display correctly?

    Thanks,

    Rosalyn
    www.guidepost.uk.com

    #2
    Have you tried searching, i'm pretty sure Norman has posted a solution to this previously. You need to use php, but he provided the complete solution, probably in the KB too.

    Comment


      #3
      Hi,

      I had searched both the KB and the forum - and have just spent ages doing so again, and can't find the answer!

      There is a reference to the solution in a post by Norman in the following thread:

      http://community.actinic.com/showthread.php?t=34846

      but, try as I might, I can't find the thread he is referring to, and the post is too old to appear in Norman's list of posts.

      Sorry if I am being dim, but my blood pressure is now rising at the frustration mof not being able to find it - any help much appreciated.

      Thanks,

      Rosalyn
      www.guidepost.uk.com

      Comment


        #4
        Have you tried this:
        <actinic:variable name="ProductName" encoding="strip"/>
        or
        <actinic:variable name="ProductDescription" encoding="strip"/>

        Comment


          #5
          Code:
          <actinic:block php="true" >
          $sShort = "";
          $nCount = 0;
          $sOriginal = "<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />"; 
          $sOriginal = preg_replace('/\!\!<|>\!\!/', '', $sOriginal); // remove!!< and >!!
          $sOriginal = preg_replace('/<.*?>/', '', $sOriginal); // remove any HTML tags
          foreach(explode(" ", $sOriginal) as $sWord)
          {
          if ($nCount > 10)
          {
          $sShort .= "...";
          break;
          }
          $sShort .= $sWord . " ";
          $nCount++;
          }
          
          echo $sShort;
          </actinic:block>
          http://community.actinic.com/archive...p/t-22153.html

          Comment


            #6
            Thank you so much - both for this, and the great advice you and a core of other very knowledgeable people post on the forum.

            regards,

            Rosalyn
            www.guidepost.uk.com

            Comment


              #7
              No control of font size

              I used this code to limit the word length of the text in the listing but i find i can nolonger change the font size of the text in the product description.

              Any ideas

              Cheers
              Ricc.


              Originally posted by leehack View Post
              Code:
              <actinic:block php="true" >
              $sShort = "";
              $nCount = 0;
              $sOriginal = "<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />"; 
              $sOriginal = preg_replace('/\!\!<|>\!\!/', '', $sOriginal); // remove!!< and >!!
              $sOriginal = preg_replace('/<.*?>/', '', $sOriginal); // remove any HTML tags
              foreach(explode(" ", $sOriginal) as $sWord)
              {
              if ($nCount > 10)
              {
              $sShort .= "...";
              break;
              }
              $sShort .= $sWord . " ";
              $nCount++;
              }
              
              echo $sShort;
              </actinic:block>
              http://community.actinic.com/archive...p/t-22153.html
              http://www.marionvillemodels.com http://www.skymonster.com

              Comment


                #8
                You can style the output by wrapping your PHP code between a styled span or div eg:

                <div class="actxxsmall"> ...PHP Code .... </div>

                that will style everything between the <div> including the PHP generated output.


                Bikster
                SellerDeck Designs and Responsive Themes

                Comment


                  #9
                  Had the same problem and altered the code a bit to match my needs. The below still allows the styling to be shown :

                  <actinic:block php="true" >
                  $sShort = "";
                  $nCount = 0;
                  $sOriginal = '<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />';
                  $sOriginal = preg_replace('/\!\!<|>\!\!/', '', $sOriginal); // remove!!< and >!!
                  foreach(explode(" ", $sOriginal) as $sWord)
                  {

                  if ($nCount > 17)
                  {
                  $sShort .= "...";
                  break;
                  }
                  $sShort .= $sWord . " ";
                  $nCount++;
                  }
                  echo $sShort;
                  </actinic:block>
                  Web design Bradford

                  Comment


                    #10
                    I have been trying to find a more even way of just showing the first few lines of the product description at section level. This method displays the first number of characters rounded to the nearest full word rather than the first number of words.

                    Code:
                    <actinic:block type="ProductList" ><div class="actxxsmall">
                    	<actinic:block php="true" >
                    $string = '<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />';
                    $string = preg_replace('/\!\!<|>\!\!/', '', $string); // remove!!< and >!!
                    $string = preg_replace('/<.*?>/', '', $string); // remove any HTML tags
                    echo neat_trim($string, 150);
                    	</actinic:block></div>
                    
                    </actinic:block>
                    Hopefully it will be useful to someone else.
                    Unusual Silver Jewellery
                    Giftmill - Unusual Gifts
                    Crystal Healing Jewellery
                    Steampunk Jewellery

                    Comment


                      #11
                      Andy. The neat_trim() function isn't part of the PHP that's bundled with Actinic.
                      Norman - www.drillpine.biz
                      Edinburgh, U K / Bitez, Turkey

                      Comment


                        #12
                        I was just about to post something similar.

                        I tried this on my laptop (Used for testing things before doing them on the real site) which is running version 10 and it worked fine.

                        I then did exactly the same on my main PC - also running version 10 - and it complained about an undefined function.
                        I then added the following code to the Actinic_Main.PHP file and after restarting Actinic it worked fine.

                        I have no idea why it should work on the laptop as I have never edited the Actinic_Main.PHP file before.

                        Code:
                        /**
                         * Cut string to n symbols and add delim but do not break words.
                         *
                         * Example:
                         * <code>
                         *  $string = 'this sentence is way too long';
                         *  echo neat_trim($string, 16);
                         * </code>
                         *
                         * Output: 'this sentence is...'
                         *
                         * @access public
                         * @param string string we are operating with
                         * @param integer character count to cut to
                         * @param string|NULL delimiter. Default: '...'
                         * @return string processed string
                         **/
                        function neat_trim($str, $n, $delim='...') {
                           $len = strlen($str);
                           if ($len > $n) {
                               preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches);
                               return rtrim($matches[1]) . $delim;
                           }
                           else {
                               return $str;
                           }
                        }
                        Unusual Silver Jewellery
                        Giftmill - Unusual Gifts
                        Crystal Healing Jewellery
                        Steampunk Jewellery

                        Comment

                        Working...
                        X