Limit RSS Feed

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
baselve

Limit RSS Feed

Post by baselve »

Hi,

Is it possible to limit the number of articles shows by the rss feed from the news module? Now the rss feed shows unlimited articles but I want it to show the last 10....

I think it must be possible trough some modifications with rss template from the news module:

Code: Select all

<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>{$sitename|escape}</title>
		<link>{$root_url}</link>
		<description>Current News entries</description>
		{foreach from=$items item=entry}
		<item>
			<title><![CDATA[{$entry->title}]]></title>
			<link>{$entry->link}</link>
			<guid>{$entry->link}</guid>
			<pubDate>{$entry->gmdate}</pubDate>
			<category><![CDATA[{$entry->category}]]></category>
			<description><![CDATA[{eval var=$entry->strippedsummary}
			{eval var=$entry->strippedcontent}]]></description>
		</item>
		{i}
		{/foreach}
	</channel>
</rss> 
Last edited by baselve on Wed Feb 14, 2007 3:55 pm, edited 1 time in total.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Limit RSS Feed

Post by Dee »

This should work (untested):

Code: Select all

<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>{$sitename|escape}</title>
		<link>{$root_url}</link>
		<description>Current News entries</description>
		{foreach from=$items item=entry name=entry}
                {if $smarty.foreach.entry.index <= 10}
		<item>
			<title><![CDATA[{$entry->title}]]></title>
			<link>{$entry->link}</link>
			<guid>{$entry->link}</guid>
			<pubDate>{$entry->gmdate}</pubDate>
			<category><![CDATA[{$entry->category}]]></category>
			<description><![CDATA[{eval var=$entry->strippedsummary}
			{eval var=$entry->strippedcontent}]]></description>
		</item>
		{i}
                {/if}                
		{/foreach}
	</channel>
</rss> 
Regards,
D
baselve

Re: Limit RSS Feed

Post by baselve »

Thanks, it works! Strange enough it shows 18 items instead of 10, but it doesn't show unlimited items now, so I'm happy!  ;D
reidjazz

Re: Limit RSS Feed

Post by reidjazz »

Could this be made to work for the normal news posts? I'd like to show only the 5 most recent posts, and then maybe have a listing of previous posts, by month, perhaps (kind of like blogger does).

Is this possible?

Todd
Locked

Return to “CMSMS Core”