Create a RSS feed without a module

  Previous article Next article  

Create a RSS feed without a module

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.3.1
  Last updated: 18-11-2017
  Comments: 0
  http://cms.ms/XJw2

I 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"

content_type
$content_type = get_parameter_value($params,'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:

{content}


3. Create a new CGBlog template "feed" and the content:

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<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:

{content_type type='application/rss+xml'}
{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:

<link rel="alternate" type="application/rss+xml" title="Your title" href="http://www.website.com/feed.rss" />

  Working example

Check the websites feed https://www.cmscanbesimple.org/feeds/blog.rss

Validate the RSS feed





CMS Made Simple 2.2.5 - Tutorials, tips and tricks - CMSMS 2.2.5

Create a RSS feed without a module

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.3.1
  Last updated: 18-11-2017
  Comments: 0
  http://cms.ms/XJw2