Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Truncate RssFeed

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 657 Views
  • Double-A-Ron
    Avatar
    Community Member
    599 Posts

    Truncate RssFeed Link to this post

    I have the following functions in my HomePage controller displaying XML to /home/rss:

    // ----------------------------------------------------------------------------
       // GET LATEST NEWS
       // ----------------------------------------------------------------------------
       function LatestNews()
       {
          $news = DataObject::get_one("ArticleHolder");
          return ($news) ? DataObject::get("ArticlePage", "", "Date DESC", "", 3) : false;
       }
       
       
       // ----------------------------------------------------------------------------
       // RSS NEWS FEED
       // ----------------------------------------------------------------------------
       function rss()
       {
          $rss = new RSSFeed(self::LatestNews(), $this->Link(), parent::GetConfig()->SiteName." - Latest News");
          $rss->outputToBrowser();
       }

    Works fine, although it pulls the entire article out in HTML format, image included (which is a separate dataobject on the pagetype rather than one inserted into the content.

    Is there a way I can output on the content portion of the object returned from LatestNews?

    Aaron

  • Double-A-Ron
    Avatar
    Community Member
    599 Posts

    Re: Truncate RssFeed Link to this post

    My mistake, the image and caption actually are in the main content of the page type.

    So all I am looking to do here is to output the Content records with HTML stripped just the same as using $Content.LimitWordCount(50) in a template.

    I can't see any options for this in the Doc. I have also had a play around with the RSSFeed class in sapphire/api. Will we really have to hand code the XML output to acheive this?

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