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.

Blog Module /

Discuss the Blog Module.

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

Creating a custom RSS feed field


Reply


3 Posts   1122 Views

Avatar
Optic Blaze

Community Member, 165 Posts

21 July 2011 at 8:30am

Hi there, i have the following challenge:

I have extended the Blog module by adding a custom description field. I use this field to write a summary of the article, so that visitors can get an overview of the article before they actually read it and it has been working well.

My problem is that the RSS feed does not make use of the custom description field at all and defaults to making use of the content of the article as the description.

I extended the Blog like this:

--------------------------------------

class BlogEntry extends Page {
   static $db = array(
      "Date" => "Datetime",
      "Author" => "Text",
      "Tags" => "Text",
      "Description" => "Text"
   );

--------------------------------------

I would like to rather use $BlogEntry.Description as the description field for the rss feed.

Thanks

Avatar
SheaDawson

Community Member, 46 Posts

1 August 2011 at 9:50pm

See this function in BlogEntry.php

function RSSContent() {
   return $this->Content();
}

This is the function called to retrieve the content for the RSS feed. You need to modify it to return your new field ie.

function RSSContent() {
   return $this->Description();
}

Technically it looks like you are hacking BlogEntry, not extending it.. you should look into how to extend a page type properly without modifying the core files. That way you can still update modules when new versions are released. Makes life easier in the long run :)

Avatar
Optic Blaze

Community Member, 165 Posts

1 August 2011 at 11:38pm

Hi there,

Thanks for posting.

I had a look at BlogEntry.php and could not find the function RSSContent(). I am using blog 0.41. The only place i could find similar code was in the saphire folder under api called RSSFeed.php but i am pretty sure that i should not be messing with that. Like you said hacking saphire could create problems.

I also tried adding the code you gave to the BlogEntry.php page, but it seemed to have had no effect.