Hi. Someone showed me how to do this without using any add-ons. I am currently using it in the 'welcome' section at the top of my gallery page:
http://www.oneuk.f2s.com/photos/Here is the code: (Let's say for this example you are using a file called 'anycontent2.php') (sorry if it's a bit long winded!)
1. Create a folder anywhere on your webserver where you will put your random images, and upload the images you want to use
2. Make a copy of the file 'anycontent.php' and rename it to anycontent2.php
3. Add the following code to this file:
<?php
$banners = array(1 => 'rand1.jpg', 2 => 'rand2.jpg', 3 => 'rand3.jpg', 4 => 'rand4.jpg');
$random = rand(1,4);
$banner = "http://www.oneuk.f2s.com/images/rand/" . $banners[$random];
echo "<p style='text-align: left'><img border=6 src='" . $banner . "' alt='' /></p>";
?>
Below is a description of the code:
<?php
$banners = array(1 => 'rand1.jpg', 2 => 'rand2.jpg', 3 => 'rand3.jpg', 4 => 'rand4.jpg'); // this is a list all of the image numbers that you will be using and their filenames
$random = rand(1,4); // this is which of the above image numbers you want to use (in this case all of them) so if you have 4 images as I have here you use "(1,4)" if you have 5 images use "(1,5)" for 10 use "(1,10)" etc etc
$banner = "http://www.oneuk.f2s.com/images/rand/" . $banners[$random]; // this is the folder where your images are located. Change for your server details obviously.
echo "<p style='text-align: left'><img border=6 src='" . $banner . "' alt='' /></p>";
?>
Now open 'index.php' and find the following code:
case 'anycontent':
if ($cat == 0) {
ob_start();
/**
* Any php code or HTML can be put in this file and will be displayed
*/
include('anycontent.php');
$anycontent = CPGPluginAPI::filter('anycontent',ob_get_contents());
ob_end_clean();
echo ($anycontent);
}
flush();
break;
and add below it: (basically change all instances of 'anycontent')
case 'anycontent2':
if ($cat == 0) {
ob_start();
/**
* Any php code or HTML can be put in this file and will be displayed
*/
include('anycontent2.php');
$anycontent2 = CPGPluginAPI::filter('anycontent2',ob_get_contents());
ob_end_clean();
echo ($anycontent2);
}
flush();
break;
That's it, it works for me!
See my gallery:
http://www.oneuk.f2s.com/photos/Refresh the page and the images at the top left of the page will change