GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   Random Rss feeds (https://gfy.com/showthread.php?t=1061044)

feelgoodmovies 03-14-2012 12:40 AM

Random Rss feeds
 
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.

rweb 03-14-2012 10:16 AM

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:
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); 

Add this in the script where there is the line "$XMLfilename = "sample.xml";" by default.

feelgoodmovies 03-15-2012 06:46 AM

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'; ?>

rweb 03-15-2012 08:04 AM

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';
?>


feelgoodmovies 03-16-2012 07:18 AM

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.

rweb 03-16-2012 02:02 PM

Sorry, I made a mistake.
PHP Code:

rand(0,sizeof($myfeeds)-1

should be actually
PHP Code:

$myfeeds[rand(0,sizeof($myfeeds)-1)] 

The include line like that
PHP Code:

include 'URL OF RSS2HTML FILE?XMLFILE='.$XMLfilename.'&TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20'

may not work on all servers.

I tested on my server. I left the rss2html.php as it was. And in index.php I put:
PHP Code:

<?PHP
$myfeeds
[]='myfeedurl1';
$myfeeds[]='myfeedurl2';
$XMLFILE $myfeeds[rand(0,sizeof($myfeeds)-1)];
$TEMPLATE "sample-template.html";
$MAXITEMS "20";
include(
"rss2html.php");
?>

And it worked. (My index.php is in the same directory as the rss2html.php.)

feelgoodmovies 03-16-2012 11:27 PM

Works like a charm.
 
Thank you very much!!!!! You rock!!!!!!!!!!!!!!!


All times are GMT -7. The time now is 02:41 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc