Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » RSS stylesheet implementation

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 909 Views
  • employboy
    Avatar
    Community Member
    9 Posts

    RSS stylesheet implementation Link to this post

    Hello there, after looking through documentation for the RSSFeed object I've discovered a glaring inadequacy. Basically I'd like to add a style sheet to my rss feed for chrome uses, for whom feed content isn't identified as being RSS (at least not in version 2.0).

    In case you don't know what I mean, take a look at this link:

    http://interglacial.com/~sburke/stuff/pretty_rss.html

    Under the heading - The XMLCSS Approach

    You can see it's just one line that I'm trying to include but RSSFeed.php is such that I can't easily see anyway to extend it to allow me to include this line. Here's hoping someone reading this has some idea.

    Thanks chaps.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: RSS stylesheet implementation Link to this post

    You can see it's just one line that I'm trying to include but RSSFeed.php is such that I can't easily see anyway to extend it to allow me to include this line. Here's hoping someone reading this has some idea.

    Could you simply subclass RSSFeed and override the specific function you want to. Then in your project code you can create a new instance of your class rather than RSSFeed.

    If you want to override the RSS feed created inside a module (like blog or forum) then you could use Object::useCustomClass('RSSFeed', 'MyRSSFeed') so that any instance of RSSFeed is changed to MyRSSFeed. You may need to check that they use Object::create('RSSFeed') to make the object - if they don't then update the code and submit patches to the respective modules.

  • employboy
    Avatar
    Community Member
    9 Posts

    Re: RSS stylesheet implementation Link to this post

    Thanks Willr, that's exactly what I ended up doing, works a charm except that it was difficult getting the xml headers in for chrome to recognise.

    Class RssStyled Extends RSSFeed{
       function feedContent(){
          $prevState = SSViewer::get_source_file_comments();
          SSViewer::set_source_file_comments(false);
          $content = str_replace(' ', ' ', $this->renderWith('RSSFeedStyled'));
          
          SSViewer::set_source_file_comments($prevState);
          
          return $content;
       }
    }

    Thanks very much for your help.

    909 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.