Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Rss Link

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

Page: 1 2
Go to End
Author Topic: 2498 Views
  • Garrett
    Avatar
    Community Member
    245 Posts

    Re: Rss Link Link to this post

    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

    2498 Views
Page: 1 2
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.