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.

Widgets /

Discuss SilverStripe Widgets.

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

Returning Feed Data as HTMLText


Reply


3 Posts   1608 Views

Avatar
KeithLeslie

Community Member, 6 Posts

13 January 2009 at 5:09pm

I have modified the CNN News reader to read my client's blog. However, I would like to return the description as HTML Text. So what happens, is I read the blog, loop through the RSS feed and create an output array just like the CNN Widget. But in my template, I want to be able to take advantage of the methods available for HTMLText object types. Is there anyway to do the following, but return one of the elements as HTMLText:

$output->push(
   new ArrayData(
      array(
         "Title" => $title,
         "URL" => $link,
         "Body" => $description
      )
   )
);

I went through just about all the widgets examples and I do not see anything that leads me to believe this is possible, but the widget examples aren't exactly pushing the edge of the envelope either. Any help would be appreciated.

Thanks!

Avatar
dio5

Community Member, 501 Posts

27 January 2009 at 10:52am

Edited: 27/01/2009 10:52am

Perhaps something like this could work:

$obj = new HTMLText("Body");
$obj->setValue($description);

$output->push(
new ArrayData(
array(
"Title" => $title,
"URL" => $link,
"Body" => $obj
)
)
);

Now Body is of the type HTMLText and can use the methods of it?

Just a guess, haven't tried this myself, but something like this could work :)

Avatar
pecos_red

Community Member, 7 Posts

27 January 2009 at 7:02pm

Edited: 27/01/2009 7:04pm

Instead of $description, try using $ParsedContent.

Not sure if that's what you're looking for, but it worked for me with local blog entries.

(To clarify, I used $ParsedContent in the template.)