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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Rss Link


Reply


9 Posts   2550 Views

Avatar
Garrett

Community Member, 245 Posts

25 March 2011 at 8:59am

I'm having a slightly different problem but am hoping you can also offer me some help, @willr. I am creating an RSS Feed for a custom DataObjectSet:

function rss() {
$rss = new RSSFeed($this->NewsroomFeed(), "", "Newsroom");
$rss->outputToBrowser();
}

I am loading up an array in NewsroomFeed() as follows:

......

$result = $query->execute();
      
foreach($result as $sqlResult) {
      
$Title = $sqlResult['Title'];
$URL = $sqlResult['URL'];

$results->push(new RSSFeedableData(array(
"Title" => $Title,
    "Link" => $URL
)));
         
}

return $results;

As you can see, I created the class you suggested since I was receiving the same error as the other guy. The $URL variable here coming from the resultset is either going to be a LOCAL site link OR an external URL, which is why I don't want to use the Page object to get the Link. In the feed, I want the link to LITERALLY be this value -- the value of the sqlresult URL field. But in RSSFeedableData::Link(), doing:

return $this->getField('URL');

Of course gives me:

Undefined index: URL

Because I am not IN the resultset at that point. There is something about the way this works that I am fundamentally not understanding. I only have two fields here, this shouldn't be too hard. How can I get $URL to replace the Link value in the feed?

Thanks as always,
Garrett