Jump to:

1856 Posts in 1610 Topics by 562 members

Blog Module

SilverStripe Forums » Blog Module » [Solved] RSS Feed - Not rendering html correctly

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 793 Views
  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    [Solved] RSS Feed - Not rendering html correctly Link to this post

    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.

  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    Re: [Solved] RSS Feed - Not rendering html correctly Link to this post

    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());

    793 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.