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.

Data Model Questions /

RSS feed on DataObjects


Reply


8 Posts   2129 Views

Avatar
cliersch

Community Member, 75 Posts

25 March 2009 at 6:01am

Hi! The tutorial shows how to use the RSSFeed for Children of the site. I would like to have DataObjects as an RSS Feed. My Problem is, the RSSFeed needs to have a LINK but I'm not able to use $this->Link() for Objects. How can I a implement a Link method for my DataObjects to use the feed?

   function init() {
      RSSFeed::linkToFeed($this->Link() . "rss", "RSS feed of this blog");
      parent::init();
   }
   
   function rss() {
      $rss = new RSSFeed($this->MyDataObject(), $this->Link(), "My feed", "Example feed.", "Title", "Content", "Author");
      $rss->outputToBrowser();
   }

Any idea?

Avatar
Howard

Community Member, 215 Posts

15 August 2009 at 4:58pm

Hey yea I would also like to do something like this, any ideas?

Avatar
bartvanirsel

Community Member, 94 Posts

17 August 2009 at 9:50pm

Hi,

I'm no expert but i think the link method in the data objects is used.

So if you create a custom Link method in your Data Object this will override the parent and will
also be used in the RSS feed.

Avatar
Howard

Community Member, 215 Posts

17 August 2009 at 10:19pm

You're right, I figured this out yesterday so can confirm that it works :)

Avatar
go2planC

Community Member, 19 Posts

13 September 2010 at 6:09am

Hi would be really usefull if you could supply the code you used here.

Thanks in advance :)

Avatar
Bauer-CTU

Community Member, 10 Posts

27 September 2010 at 11:33pm

Edited: 27/09/2010 11:36pm

Like the OP I'm trying to create a RSS feed from DataObjects which do not each have their own page. However, I can't see how to create the custom Link method that is required. All the RSS entries for my feed should point to the same page where the Data Objects are listed.

So, I'd second go2planC - the code would be useful.

Thanks.

Avatar
Willr

Forum Moderator, 5513 Posts

29 September 2010 at 6:15pm

Edited: 29/09/2010 6:16pm

However, I can't see how to create the custom Link method that is required. All the RSS entries for my feed should point to the same page where the Data Objects are listed.

Well you answered your own question. The page which stores your DataObject must have a URL of some sort which you can use as the return value from Link. Eg if you had a ListPage which printed out a list of objects your link function might look like

function Link() {
$holder = DataObject::get_one('ListPage');

return ($holder) ? $holder->Link() . '#item-'. $this->ID : false;

Which will generate you a link like http://yoursite.com/listpageurl#item-2. The #item-2 part is an anchor which if you're displaying posts all on the same page you can jump straight to item-2 if you have something like this setup in your html.

<div id="item-{$ID}">
// ...
</div>

If you don't want to link to anywhere just create a blank link function which links to say the homepage

function Link() {
return 'home';
}

Avatar
Bauer-CTU

Community Member, 10 Posts

29 September 2010 at 9:51pm

Thanks Willr. I'll give that a go.