Jump to:

1844 Posts in 1600 Topics by 559 members

Blog Module

SilverStripe Forums » Blog Module » Creating a custom RSS feed field

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 1056 Views
  • Optic Blaze
    Avatar
    Community Member
    161 Posts

    Creating a custom RSS feed field Link to this post

    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

  • SheaDawson
    Avatar
    Community Member
    45 Posts

    Re: Creating a custom RSS feed field Link to this post

    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

  • Optic Blaze
    Avatar
    Community Member
    161 Posts

    Re: Creating a custom RSS feed field Link to this post

    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.

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