1776 Posts in 498 Topics by 533 members
Blog Module
SilverStripe Forums » Blog Module » Creating a custom RSS feed field
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 811 Views |
-
Creating a custom RSS feed field

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
-
Re: Creating a custom RSS feed field

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
-
Re: Creating a custom RSS feed field

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.
| 811 Views | ||
|
Page:
1
|
Go to Top |


