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!
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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!
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...
Sorry, my idea didnt even work when I tried it :( should stop coding off the top of my head!