Create a RSS feed without a module
Previous article Next articleI will show you an example RSS feed in combination with the CGBlog module for CMS Made Simple. You can also use it for several other modules, like News, CGCalendar, etc. You need to change the Smarty tags in the feed template matching with the module used.
How to use
1. Create a new User Defined Tag named "content_type"
if ($content_type != '') { cmsms()->set_content_type($content_type); }
2. Create in Design Manager a new Core::Page Template named "blank", that only contains:
3. Create a new CGBlog template "feed" and the content:
<channel>
<atom:link href="{root_url}/feed.rss" rel="self" type="application/rss+xml" />
<title>{sitename}</title>
<link>{root_url}/blog</link>
<description>Your description of this feed</description>
<copyright>Your name</copyright>
<generator>CMS Made Simple</generator>
{foreach from=$items item=entry}
<item>
<title>{$entry->title|escape}</title>
<description>{strip}
{eval var=$entry->summary|default:$entry->content|strip_tags:false|escape|strip|truncate:400}
{/strip}</description>
<guid>{$entry->detail_url}</guid>
<link>{$entry->detail_url}</link>
<pubDate>{$entry->postdate|rfc_date}</pubDate>
</item>
{/foreach}
</channel>
</rss>
4. Create a new content page "Feed". In the options tab of the page editor you must use the new Core::Page template "blank" and set the page non-searchable, not in menu and WYSIWYG switched off!
In the page content you put:
{CGBlog number='5' summarytemplate='feed'}
Set in options tab Page URL: feed.rss
You can test your feed at www.website.com/feed.rss
4. (optional) For the auto discovery of the feed by webbrowsers, you can add in the head of your template:
Working example
Check the websites feed https://www.cmscanbesimple.org/feeds/blog.rss
Comment Form
ReviewManager
ReviewManager
18 Comments
For News module urls you can use {$entry->moreurl}
Hi Rolf,
I used your example but am using the News module. for the element I had to use: {$entry->link}
Unfortunatelly the URL now is encoded twice
instead of
https://rk1.rosakehlchen.de/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=103&cntnt01origid=56&cntnt01pagelimit=2&cntnt01returnid=56
I get
https://rk1.rosakehlchen.de/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=103&cntnt01origid=56&cntnt01pagelimit=2&cntnt01returnid=56
What's wrong here?
Regards,
Matthias
I updated the article so it also works with the new Smarty Scope that was introduced in CMSMS 1.12 and 2.0
The blog module is good but lacks the rss and sitemap. Combining your code and running the rss output means we can distribute the feed and run it through feedburner. the sitemap is vital as the normal cmsms doesnt pick up the posts.
@sigma_web
love your site and the tips. thank you
HI
To display RSS of the pages I modified your code, but I can not display "description":
{content_type type='text/xml'}
domain.com
http://www.domain.com
domain.com
domain.com
domain.com
{menu assign='dump'}
{if $count > 0}
{foreach from=$nodelist item=node}
{if $node->type == 'advanced_content'}
{$node->menutext}
{$node->url}
{strip}
??????????????????????
{/strip}
{$node->modified|date_format:'%Y-%m-%d'}
{$node->url}
{/if}
{/foreach}
{/if}
Would you have a solution?
Thank you
Thank you for your helpful solution.
I would like to know how I can change the script to create RSS for pages (contents)?
Thanks
For anyone else having a problem with RSS feed content not appearing after setting up Rolf's excellent RSS solution. I needed to remove SEOTools2 module. This module added the tag which blocked the content from showing.
I have reviewed the code and each step. I have no idea where the is coming from. Everything is setup per the above directions. Could this possibly be in the CBlog template somewhere?
@elkman
When looking in the page source of your feed it contains a <base href="..."> tag in the item sections, which shouldn't be there...
Please check step #2 above.
The blank template must be attached to the feed page!
I have created the RSS feed as shown. Seems to have worked exactly as described.
Here is a problem I have that I can't figure out. The created page doesn't show any of the blog items. If you look at the page code it appears they are listed just not appearing. The links seem to be the problem. Is there a different template that I should be using so the blog listings appear similar to your example page?
http://www.jannahoiberg.com/index.php?page=feed-rss
Thanks for your many tips and tricks. I use them all of the time. This is my first use of CGBlog and now your RSS feed code.
Fun and informative. THX
I updated the article. It doesn't use a separate CGBlog summary template anymore, but instead all code is entered in the content page. It is simpler and more in line with other blog articles of mine.
@benhenda
Go in the CMSMS Admin to:
Layout >> Templates and click: "Add new template"
Hi
Your tutos are very helpful, but I always get confused when it is question of creating a "HTML template". What do you mean by that and how to do it in cmsms ? My question may sound awkward, but I am stuck there. Sorry
Thanks
ben
You could use a .htaccess file and rewrite the url. But upgrading is a faster solution, anyway it is certainly the best step!
Hi,
I'm also using an old installation (so I understand why you can't support it) that doesn't allow "." in the page URL. This is the error message:
"The page URL specified is invalid. It should contain only alphanumeric characters, or - or /. It is also possible that the URL specified is already in use."
Is there a way to set that URL anyway? Directly in the database with the help of Phpmyadmin perhaps? Or is it possible to disable the URL check that generates the error?
You probably tried to set the page alias, here is a dot not allowed. The Page Url is a different field!! You need to fill in this field...
Hi Rolf,
thanks for your solution, but I've one problem; I can't change the page url to "feed.rss" , no "dot" is allowed. I'm using CMSMS 1.10.2, is it nescesary to update?
Thanks.
I'm using it with {news} by the way.
Brent