Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

*bold* erm?


Go to End


10 Posts   3334 Views

Avatar
FireMe!

Community Member, 74 Posts

20 July 2009 at 2:36am

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

Avatar
mhull

Community Member, 79 Posts

20 July 2009 at 3:20am

Edited: 20/07/2009 3:25am

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

Avatar
FireMe!

Community Member, 74 Posts

20 July 2009 at 3:26am

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

Avatar
mhull

Community Member, 79 Posts

20 July 2009 at 9:18pm

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?

Avatar
mhull

Community Member, 79 Posts

20 July 2009 at 11:29pm

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?

Avatar
mhull

Community Member, 79 Posts

21 July 2009 at 8:48am

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?

Avatar
bummzack

Community Member, 904 Posts

21 July 2009 at 6:12pm

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

Avatar
mhull

Community Member, 79 Posts

21 July 2009 at 8:19pm

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.

Go to Top