Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » RSS feed

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1401 Views
  • carenas1
    Avatar
    Community Member
    3 Posts

    RSS feed Link to this post

    Hello,
    Could anyone help me?
    I have rss feed for my website but it is showing 10 full articles. I need, that in RSS feed would be shown only 10 titles of articles and only first paragraph of article. Please write the code, it would be great!

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: RSS feed Link to this post

    When you create a RSS feed you do something like this... (taken from the blog module)

    $rss = new RSSFeed($children, $this->Link(), $project . " blog", "", "Title", "ParsedContent");

    The last argument in that list points to a method on BlogEntry which produces the content. So say you want the RSS Feed to show the first paragraph you could change that new RSS Feed to something like...

    $rss = new RSSFeed($children, $this->Link(), $project . " blog", "", "Title", "MyShortContent");

    Then on whatever Page type you are making the RSS feed of (for example a RSS feed of latest NewsPages) you would open up the NewsPages.php file and write a MyShortContent Method in the main class - not the controller that goes something like

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

    Which will return the first paragraph of text from Content. Hopefully something like that will work for you!

  • carenas1
    Avatar
    Community Member
    3 Posts

    Re: RSS feed Link to this post

    I can't understand...
    I have page.php in which is rss feed.

    The page.php source:
    <?php

    class Page extends SiteTree {
       static $db = array(
       'Date' => 'Date',
       'Author' => 'Text'
       );

       static $has_one = array(
       );

       static $icon = "themes/treeicons/news";
    }

    class Page_Controller extends ContentController {
          function project() {
          global $project;
           return $project;
       }   
       
       function init() {
          RSSFeed::linkToFeed($this->Link() . "rss", "e-sviesa.lt - informacinis portalas");
          parent::init();
                Requirements::themedCSS("layout");
          Requirements::themedCSS("typography");
          Requirements::themedCSS("form");
       }
       
       function rss() {
          $rss = new RSSFeed($this->Latest(), $this->Link(), "e-sviesa.lt - informacinis portalas", "e-sviesa.lt - informacinis portalas", "Title", "Content" , "Author");
          $rss->outputToBrowser();
       }

       function Latest() {
          return DataObject::get("Page", "", "Created DESC", "", 10);
       }

       
    }

    ?>

    And I need that latest articles would be only from title and first paragraph of article...

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: RSS feed Link to this post

    Sorry, my idea didnt even work when I tried it should stop coding off the top of my head!

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