Jump to:

791 Posts in 369 Topics by 303 members

Widgets

SilverStripe Forums » Widgets » Returning Feed Data as HTMLText

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1498 Views
  • KeithLeslie
    Avatar
    Community Member
    6 Posts

    Returning Feed Data as HTMLText Link to this post

    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!

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Returning Feed Data as HTMLText Link to this post

    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

  • pecos_red
    Avatar
    Community Member
    7 Posts

    Re: Returning Feed Data as HTMLText Link to this post

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

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