Jump to:

5451 Posts in 1673 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » HTMLText Question

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

Page: 1
Go to End
Author Topic: 1795 Views
  • DanStephenson
    Avatar
    Community Member
    115 Posts

    HTMLText Question Link to this post

    Hello,

    I am reading the documentation on HTMLText useage in a template (http://doc.silverstripe.org/doku.php?id=htmltext), and was wondering if I can combine some of the different displays.

    For example, what if I wanted to display the first 10 words, but strip out all HTML. Could I use something like

    $Content.NoHTML.LimitWordCount(10)

    What I am finding, by just using the LimitWordCount, is that bold text is appearing with a ** around it, which I'd like to avoid for this display.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: HTMLText Question Link to this post

    Nope, you can't chain these commands in the template. Workaround: Make a custom controller method, e.g.
    function ContentNoHtmlLimitWordCount() {
    $content = $this->obj('Content')->NoHTML();
    return $content->LimitWordCount(10);
    }

    Ugly, but does the job...

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: HTMLText Question Link to this post

    I've added a ticket describing a fix that will make it easier to change NoHTML and LimitWordCount - http://open.silverstripe.com/ticket/3728

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