After scouring this forum, hot scripts and google with no luck- I have a question. Does anyone know a way to have rss feeds randomly display on your non-wordpress site. In other words I want to shuffle say ten different rss feeds and have one display content each time web page is loaded. I have the displaying part down(using rss2html and I also used an awesome script provided by this forum) but can't figure out the random(shuffling) part. Thanks.
Random Rss feeds
Collapse
X
-
Tags: None
-
If you're using the rss2html php-script which can be downloaded from www[dot]feedforall[dot]com/more-php.htm then you can add something like that in this script:
Add this in the script where there is the line "$XMLfilename = "sample.xml";" by default.PHP Code:$myfeeds[]='url_of_the_feed_1'; $myfeeds[]='url_of_the_feed_2'; $myfeeds[]='url_of_the_feed_3'; $myfeeds[]='url_of_the_feed_4'; $myfeeds[]='url_of_the_feed_5'; $myfeeds[]='url_of_the_feed_6'; $myfeeds[]='url_of_the_feed_7'; $myfeeds[]='url_of_the_feed_8'; $myfeeds[]='url_of_the_feed_9'; $myfeeds[]='url_of_the_feed_10'; $XMLfilename = rand(0,sizeof($myfeeds)-1); -
How do I call that
Thanks much for your help. So, I have replaced in the rss2html.php file like you mentioned. Now I am wondering how do I call this from my index.php page. Normally with rss2html you call with the following:
<?php include'URL OF RSS2HTML FILE?XMLFILE=YOUR RSS FEED URL&TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20'; ?>Comment
-
Just remove the "XMLFILE=YOUR RSS FEED URL" part. Then it will use the random feed that you configured in the rss2html.php
Like that:
<?php include'URL OF RSS2HTML FILE?TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20'; ?>
Or you can leave the rss2html.php as it is by default and do the randomization in your index.php file. In that case you should write in your index.php:
PHP Code:<?php $myfeeds[]='url_of_the_feed_1'; $myfeeds[]='url_of_the_feed_2'; $myfeeds[]='url_of_the_feed_3'; $myfeeds[]='url_of_the_feed_4'; $myfeeds[]='url_of_the_feed_5'; $myfeeds[]='url_of_the_feed_6'; $myfeeds[]='url_of_the_feed_7'; $myfeeds[]='url_of_the_feed_8'; $myfeeds[]='url_of_the_feed_9'; $myfeeds[]='url_of_the_feed_10'; $XMLfilename = rand(0,sizeof($myfeeds)-1); include 'URL OF RSS2HTML FILE?XMLFILE='.$XMLfilename.'&TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20'; ?>Comment
-
Configuration error message.
Thanks for your help. I tried both examples above and am getting the following error message: Unable to open RSS Feed 6, exiting Unable to open RSS Feed sample.xml, exiting .
I made sure all files are chmod to 755 and changed this line in the rss2html.php script:
$fileAccessLevel = 1;
to this:
$fileAccessLevel = 0;
per their forum.Comment
-
Sorry, I made a mistake.
should be actuallyPHP Code:rand(0,sizeof($myfeeds)-1)
The include line like thatPHP Code:$myfeeds[rand(0,sizeof($myfeeds)-1)]
may not work on all servers.PHP Code:include 'URL OF RSS2HTML FILE?XMLFILE='.$XMLfilename.'&TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20';
I tested on my server. I left the rss2html.php as it was. And in index.php I put:
And it worked. (My index.php is in the same directory as the rss2html.php.)PHP Code:<?PHP $myfeeds[]='myfeedurl1'; $myfeeds[]='myfeedurl2'; $XMLFILE = $myfeeds[rand(0,sizeof($myfeeds)-1)]; $TEMPLATE = "sample-template.html"; $MAXITEMS = "20"; include("rss2html.php"); ?>Comment
-

Comment