Forum Discussion

nickyates's avatar
nickyates
Mentor
12 years ago

how do i truncate an article body

I would like to truncate the text in the body of a blog article.  I have used the freemarker substring function to do this however if any styling is added to the blog body text the closing tags are lost and the page looks broken.  Is there any way to truncate this text without losing the formatting?

  • Is this even possible using Lithium? If not I will search for another solution
    • VenkS's avatar
      VenkS
      Lithium Alumni (Retired)

      The only way I know to do this would be to write a function that takes the body text, then get the substring text, then look within that substring for any open tags, and add closing tags to the end of the substring.

       

      The other option you have would be to HTML escape the body text to remove all HTML tags, then use that flat text.