Page 1 of 2

Is there a way to limit RSS feeds?

Posted: Tue Jun 09, 2009 3:02 pm
by schimanke
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?

Re: Is there a way to limit RSS feeds?

Posted: Tue Jun 09, 2009 4:21 pm
by garvinhicking
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:

Code: Select all

$serendipity['RSSfetchLimit'] = (int)$_REQUEST['limit'];
just after the line

Code: Select all

@define('IN_RSS', true);
include('serendipity_config.inc.php');
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

Re: Is there a way to limit RSS feeds?

Posted: Tue Jun 09, 2009 4:44 pm
by schimanke
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

Re: Is there a way to limit RSS feeds?

Posted: Tue Jun 09, 2009 4:49 pm
by garvinhicking
Hi!

Ah, of course. You could then use:

Code: Select all

if (isset($_REQUEST['limit'])) {
  $serendipity['RSSfetchLimit'] =(int)$_REQUEST['limit'];
}
Regards,
Garvin

Re: Is there a way to limit RSS feeds?

Posted: Tue Jun 09, 2009 5:56 pm
by schimanke
Thanks, Garvin!
Now it works just perfectly!!!

Re: Is there a way to limit RSS feeds?

Posted: Tue Apr 09, 2019 5:01 pm
by schimanke
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?

Posted: Thu Apr 11, 2019 12:18 am
by onli
Which error do you get exactly?

Re: Is there a way to limit RSS feeds?

Posted: Thu Apr 11, 2019 10:04 am
by schimanke
The exact error message is
Parse error: syntax error, unexpected '$serendipity' (T_VARIABLE) in /[...]/rss.php on line 41
This is the section in which I added the code:

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';
}
And line 41 from the error message is this one:

Code: Select all

$serendipity['RSSfetchLimit'] =(int)$_REQUEST['limit'];
Thanks for your help!

Re: Is there a way to limit RSS feeds?

Posted: Thu Apr 11, 2019 3:20 pm
by onli
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?

Re: Is there a way to limit RSS feeds?

Posted: Thu Apr 11, 2019 3:25 pm
by schimanke
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?

Posted: Thu Apr 11, 2019 5:30 pm
by onli
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?

Posted: Fri Apr 12, 2019 11:44 am
by schimanke
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!

Re: Is there a way to limit RSS feeds?

Posted: Fri Apr 12, 2019 3:10 pm
by onli
That works fine.

I got an error in line 6:

Code: Select all

session_cache_limiter('public');
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?

Re: Is there a way to limit RSS feeds?

Posted: Sat Apr 13, 2019 8:07 am
by schimanke
I got an error in line 6.
That's even more weird... :?

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?

Posted: Sat Apr 13, 2019 12:48 pm
by onli
That's utterly strange. Which PHP version do you use? Are there error messages in the webserver log?