SilverCart Forum
We moderate this Forum and we're here to help. Have you already run a forum search to check if your problem has already been solved?
You can help us helping you by providing detailed error messages, screenshots and logfile entries.
Page: 1 | ||
Topic HTML Free Text Widget? | 2122 Views |
HTML Free Text Widget?
14 October 2013 at 5:30pm Last edited: 14 October 2013 10:18pmHi,
How can I easily extend or maybe modify by means of DataObject decoration the Free Text widget to display HTML text instead of the plain text one?
I tried to figure it out on my own, but no success so far.
Any help appreciated :)
thanx in advance
Szabesz
Re: HTML Free Text Widget?
15 October 2013 at 5:47pmHi Gábor,
to display the pure text without rendering the HTML you can copy SilvercartTextWidget.ss into your project and change it as follows:
<% if Headline %>
<h2>$Headline</h2>
<% end_if %>
<div class="silvercart-widget-content_frame $ExtraCssClasses">
$FreeText.HTML
</div>
Cheers
Ramon
Re: HTML Free Text Widget?
15 October 2013 at 6:01pmHi Ramon,
Is that sooooo easy? Well, SilverStripe rocks :)
I should have remembered this, 'cos I'm sure I used to read about it in the past, but I just forgot this feature. Well, practice makes perfect :)
Thanx a lot!
Gábor
Re: HTML Free Text Widget?
17 October 2013 at 9:31am Last edited: 17 October 2013 9:32amHi Ramon,
I'm a bit embarrassed, since your standard SilverCart template should not be overridden at all, as it reads:
<div class="silvercart-widget-content_frame $ExtraCssClasses">
$FreeText.RAW
</div>
And .RAW is what I want, I just have to type and save plain HTML in the CMS, and it renders fine in the browser, as expected.
Looking up the topic of placeholder casting, I do not seem to find .HTML as a valid escaping method. The method .XML should be used I suppose: http://doc.silverstripe.com/framework/en/reference/templates
In most cases .RAW is just fine too, since this input comes from a CMS user we should trust.
Cheers
Szabesz
Re: HTML Free Text Widget?
17 October 2013 at 2:21pmHi Gábor,
no big deal, I thought you wanted to display the pure and unrendered HTML for some reason ;-)
Cheers
Ramon