Is there a way to limit RSS feeds?
Is there a way to limit RSS feeds?
Hi there,
I'm wondering if there was a way to offer RSS feeds with different numbers of entries. I know that there is an option in the admin-panel to set the number of entries in the feed. What I would like to do is to offer the user to decide how many entries they want to see. An example would be the following feed from Apple: http://ax.itunes.apple.com/WebObjects/M ... 15/rss.xml
There you can alter the "limit=" part to decide how many entries (here 15) the feed should contain. Is something like that possible with the RSS feeds in s9y?
I'm wondering if there was a way to offer RSS feeds with different numbers of entries. I know that there is an option in the admin-panel to set the number of entries in the feed. What I would like to do is to offer the user to decide how many entries they want to see. An example would be the following feed from Apple: http://ax.itunes.apple.com/WebObjects/M ... 15/rss.xml
There you can alter the "limit=" part to decide how many entries (here 15) the feed should contain. Is something like that possible with the RSS feeds in s9y?
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Is there a way to limit RSS feeds?
Hi!
Actually this is pretty easy to hack, but s9y usually delibaretly does not allow this to leave the power of bandwidth consumption up to the blog owner, not the user.
You can pretty easily patch it into the rss.php file though, if you add this:
just after the line
Basically, you could also create a simple plugin that sets this variable, but that would be more overhead and more for me to type
Then you can call the feed via http://url/rss.php?version=2.0&limit=42 for example.
HTH,
Garvin
Actually this is pretty easy to hack, but s9y usually delibaretly does not allow this to leave the power of bandwidth consumption up to the blog owner, not the user.
You can pretty easily patch it into the rss.php file though, if you add this:
Code: Select all
$serendipity['RSSfetchLimit'] = (int)$_REQUEST['limit'];
Code: Select all
@define('IN_RSS', true);
include('serendipity_config.inc.php');
Then you can call the feed via http://url/rss.php?version=2.0&limit=42 for example.
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Is there a way to limit RSS feeds?
Hi Garvin,
thanks for your help. That works pretty good. Unfortunately with this solution you always have to set the limit variable. Otherwise you end up with a mistake. That leads me to another question. Is there a way to set a default value that is used when no limit variable is set?
Regards,
Flo
thanks for your help. That works pretty good. Unfortunately with this solution you always have to set the limit variable. Otherwise you end up with a mistake. That leads me to another question. Is there a way to set a default value that is used when no limit variable is set?
Regards,
Flo
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Is there a way to limit RSS feeds?
Hi!
Ah, of course. You could then use:
Regards,
Garvin
Ah, of course. You could then use:
Code: Select all
if (isset($_REQUEST['limit'])) {
$serendipity['RSSfetchLimit'] =(int)$_REQUEST['limit'];
}
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Is there a way to limit RSS feeds?
Thanks, Garvin!
Now it works just perfectly!!!
Now it works just perfectly!!!
Re: Is there a way to limit RSS feeds?
Sorry to bring this issue back up but the solution does no longer work since my last s9y update to version 2.1.4. When adding that code block to the rss.php I get an error on loading my RSS feed. Any way to get it working again? Thanks!
Re: Is there a way to limit RSS feeds?
Which error do you get exactly?
Re: Is there a way to limit RSS feeds?
The exact error message is
And line 41 from the error message is this one:
Thanks for your help!
This is the section in which I added the code:Parse error: syntax error, unexpected '$serendipity' (T_VARIABLE) in /[...]/rss.php on line 41
Code: Select all
if (isset($_GET['category'])) {
$serendipity['GET']['category'] = $_GET['category'];
}
if (isset($_GET['viewAuthor'])) {
$serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'];
}
if (isset($_REQUEST['limit'])) {
$serendipity['RSSfetchLimit'] =(int)$_REQUEST['limit'];
}
if (!isset($_GET['type'])) {
$_GET['type'] = 'content';
}
Code: Select all
$serendipity['RSSfetchLimit'] =(int)$_REQUEST['limit'];
Re: Is there a way to limit RSS feeds?
There is a syntax error somewhere in the code, and in the code you showed I do not notice one. And I did just test the line, the code works fine/does not throw an error
How do you upload the changed code? Are you absolutely certain there are no other modifications?
How do you upload the changed code? Are you absolutely certain there are no other modifications?
Re: Is there a way to limit RSS feeds?
Yes I am. I have uploaded the rss.php file via FTP. If the code above is included I get the error on accessing the RSS feed. If the code lines are commented out in the rss.php file, the feed is displayed correctly.
Re: Is there a way to limit RSS feeds?
FTP has transport modes which can introduce errors like that, but I guess commenting out the code wouldn't fix it then. Could you please upload the complete file somewhere? I'll have a closer look.
Re: Is there a way to limit RSS feeds?
Sure, here you go: https://www.dropbox.com/s/msldx59mxouuni6/rss.zip?dl=0
The relevant code is in line 40 to 42.
Thanks again!
The relevant code is in line 40 to 42.
Thanks again!
Re: Is there a way to limit RSS feeds?
That works fine.
I got an error in line 6:
That had to be commented out. But line 40 to 42 are valud PHP and do not cause errors.
I'd try to add those lines with ssh, does your hoster give you ssh access?
I got an error in line 6:
Code: Select all
session_cache_limiter('public');
I'd try to add those lines with ssh, does your hoster give you ssh access?
Re: Is there a way to limit RSS feeds?
That's even more weird...I got an error in line 6.
I have tried changing the lines via SSH but to no avail. The error remains the same.
Re: Is there a way to limit RSS feeds?
That's utterly strange. Which PHP version do you use? Are there error messages in the webserver log?