Jump to:

23373 Posts in 18175 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » *bold* erm?

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 2
Go to End
Author Topic: 1769 Views
  • FireMe!
    Avatar
    Community Member
    74 Posts

    *bold* erm? Link to this post

    Hi Guys

    If I use and article page or blog or anything else if I call it to display on another page, Then the text that is in bold is displayed with asterisk around what is meant to be bold like this *bold* is this a simple css problem, whats the best way to fix it?

    Thanks in advance

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: *bold* erm? Link to this post

    I am looking into the same problem, when I add $Content.LimitWordCount(30)
    it removes the strong tag and leaves the asterix's around the text. Removing the limit, and leaving content makes it display correctly.

    This is the article I can find on variables, all have the same affect.
    http://doc.silverstripe.org/doku.php?id=htmltext

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: *bold* erm? Link to this post

    yep, same problem, has anyone solved this problem? thanks in advance

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: *bold* erm? Link to this post

    FireMe! any further to finding a solution to this problem?

    I have been trawling through the forums, and found questions regarding this for both styles and images but I can't find a solution.

    why isn't articlepage bringing through any of the styles? or formatting?

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: *bold* erm? Link to this post

    I found these posts regarding the issue, it seems that the html is being stripped out leaving the asterisks:

    http://www.silverstripe.org/customising-the-cms/show/255639#post255639
    http://www.silverstripe.org/archive/show/248933#post248933
    http://www.silverstripe.org/template-questions/show/259050#post259050

    Sadly these don't seem to answer the problem, anyone have a solution?

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: *bold* erm? Link to this post

    Well so far the best I have found is to use:

    $Content.Summary(60)

    which is removing the asterisks, but also removing all the Html formatting. Does anybody have an answer on how to show a portion of the content without losing the formatting?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: *bold* erm? Link to this post

    Well, the problem with cutting the html is, that you might cut your content in between opening and closing tags.
    Something like:
    Lorem ipsum <strong>dolor sit amet, consectetur</strong> adipiscing elit.
    Might end up like this:
    Lorem ipsum <strong>dolor sit amet
    or like this:
    Lorem ipsum <strong>dolor sit amet, consectetur</st
    which is even worse. You'll end up with invalid html code in either of these scenarios.

    This is quite a tricky problem, and converting to plain text is by far the easiest solution. If you find a good algorithm to limit the character or word count of html code, without generating invalid html, then you could implement your own text-parser: http://api.silverstripe.com/default/TextParser.html

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: *bold* erm? Link to this post

    I am not sure how I would implement a text parser. Is there any examples?

    I have been looking at the blog module, looking at the code could I use something from here to pull a limited text.
    How about the following? could it be adapted?

       /**
        * Get a bbcode parsed summary of the blog entry
        */
       function ParagraphSummary(){
          if(self::$allow_wysiwyg_editing) {
             return $this->obj('Content')->FirstParagraph('html');
          } else {
             $parser = new BBCodeParser($this->Content);
             $html = new HTMLText('Content');
             $html->setValue($parser->parse());
             return $html->FirstParagraph('html');
          }
       }

    unfortunately this is just returning the whole text with code.
    Is there a simple answer to this, I need to use this a lot in the site I am building.

    1769 Views
Page: 1 2
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.