Jump to:

23576 Posts in 19403 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » LimitWordCount strips out html?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 996 Views
  • Ryan M.
    Community Member
    309 Posts

    LimitWordCount strips out html? Link to this post

    I found that using LimitWordCount on a HTMLText field, such as: $Content.LimitWordCount(20) tends to strip out any html elements within and the result is:

    <dd>Check out this review from
    for my latest film, THAT'S WHAT I AM. Opens in limited
    release on April 29, 2011 and...</dd>

    Is there any other HTML-friendly method I can use instead, or is there a work-around for this?

  • swaiba
    Forum Moderator
    1796 Posts

    Re: LimitWordCount strips out html? Link to this post

    it doesn't seem to, it does - in order to count the number of words it removes the html code. It's not very straight forward I did write out some pseudo code but due to not being able to see my previous posts I cannot find it. The main concern is if you have a html like this...

    <table><tbody><tr><td>This is more than five words right here</td></tr></tbody></table>

    And then you get the first 5 words... it could damage the structure of your HTML displayed ont eh page very badly. Still very intrested in a solution... if there is one...

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.