Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hi,

I created an RSS feed for my website with the method described in the Couch tutorial, and it works perfectly.

Now I need to create a single post RSS file, for each post dynamically, is it possible with couch?

It's done in Wordpress, so I guess it is a possibility...

regards,
Paolo
Hi Paolo,

Sorry for my ignorance but could you please let me know a bit more about 'one post RSS'?
Do you mean it should list comments on the single post or is it something else?

Thanks
Hi KK,

I mean for example for this post:

http://art-news.vietnamsales.com/fernan ... ro-volume/

RSS: http://art-news.vietnamsales.com/feed/
Which list the last posts

Single post RSS: http://art-news.vietnamsales.com/fernan ... comments=1
List only one post
Hi,

what you're trying to do is more or less the same as in the blog tutorial. You should implement the part where it says
<cms:if k_is_page> and follow the exact same pattern as described.

Short explanation is: the is_page part would give you the single post possibility and is accessed with the query param for a specific item.
THEN, IF NOT A PAGE, YOU CAN IMPLEMENT THE FULL RSS FOR THE LIST OF ITEMS...

HOPE THAT HELPS.

EDIT: I hate Caps Lock ;)
What URL structure would you prefer for this?
http://www.yoursite.com/rss/?id=55
http://www.yoursite.com/blog/post.html?feed=1

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.
If it helps? It works perfectly.

Thanks a lot, you're the best!

Paolo E
You are welcome, Paolo :)
8 posts Page 1 of 1