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.

Blog Module /

Discuss the Blog Module.

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

[Solved] RSS Feed - Not rendering html correctly


Go to End


2 Posts   1682 Views

Avatar
Blackthorn87

Community Member, 34 Posts

1 May 2012 at 9:32pm

Edited: 01/05/2012 9:33pm

Hey Guys,

I am currently trying to render an RSS Feed which contains html elements. I have duplicated and editted the RSS Widget that comes with the Blog module by changing this line:

$desc->setValue(strip_tags($item->get_description(),"&"));

for this line:

$desc->setValue($item->get_description(html));

This has left in the html that the strip_tags command was taking out, but is rendering the "< >" as "&lt; &gt;".

In the template that is rendering the description I have tried this:

<ul class="Articles">
	<% control FeedItems2 %>
		<li class="$EvenOdd<% if First %> first<% end_if %><% if Last %> last<% end_if %>">
			<h4><a name="Article-0$Pos"></a>$Title</h4>
			$Description
		</li>
	<% end_control %>
</ul>

and this

<ul class="Articles">
	<% control FeedItems2 %>
		<li class="$EvenOdd<% if First %> first<% end_if %><% if Last %> last<% end_if %>">
			<h4><a name="Article-0$Pos"></a>$Title</h4>
			$Description.EscapeXML
		</li>
	<% end_control %>
</ul>

But it still isn't rendering the html correctly.

Any help would be much appreciated!

Thanks again.

Avatar
Blackthorn87

Community Member, 34 Posts

1 May 2012 at 10:01pm

Solved!

By adding HTML in front of Text when defining the $desc variable:

From:

$desc = new Text('Description');

to:

$desc = new HTMLText('Description');

before this line in the RSSWidget.php file

$desc->setValue($item->get_description());