by
KK » Mon Sep 16, 2013 1:54 pm
Both the approaches are valid but since, presumably, we already have a separate template for RSS listing, I think the first URL approach should be preferable and so that is the one I describe below.
@PaoloE
Displaying only a single page will require passing that page's id to the RSS template.
The following code in the page_view of any template will add the page's id to the link that brings up the RSS template -
- Code: Select all
<a href="<cms:add_querystring "<cms:link 'rss.php' />" "id=<cms:show k_page_id />" />">Feed</a>
That was the first step.
As the last step we need to make slight changes to our RSS template to take into consideration any page id that might be supplied.
Following is our sample template from docs that does just this. I've highlighted the modifications.
<?php require_once( 'couch/cms.php' ); ?>
<cms:content_type 'text/xml' /><cms:concat '<' '?xml version="1.0" encoding="' k_site_charset '"?' '>' />
<rss version="2.0">
<cms:php>
global $FUNCS, $CTX;
$id = ( isset($_GET['id']) && $FUNCS->is_non_zero_natural($_GET['id']) ) ? (int)$_GET['id'] : null;
if( !is_null($id) ) $CTX->set( 'my_page_id', $id, 'global' );
</cms:php>
<channel>
<title>My News Channel</title>
<link><cms:show k_site_link /></link>
<description>Description of this channel.</description>
<language>en-us</language>
<pubDate><cms:date format='D, d M Y H:i:s' gmt='1'/> GMT</pubDate>
<generator>CouchCMS</generator>
<cms:pages masterpage='property.php' id=my_page_id limit="10">
<item>
<title><cms:show k_page_title /></title>
<link><cms:show k_page_link /></link>
<description>
<cms:html_encode>
<cms:excerptHTML><cms:show my_news_text /></cms:excerptHTML>
</cms:html_encode>
</description>
<pubDate><cms:date k_page_date format='D, d M Y H:i:s' gmt='1'/> GMT</pubDate>
</item>
</cms:pages>
</channel>
</rss>
<?php COUCH::invoke(); ?>
Hope this helps.