Printable Version of Topic

Click here to view this topic in its original format

-=Reborn JEDI=- Forums _ phpTalk _ Just A Simple Question... ^_^

Posted by: DarkSykes Dec 18 2003, 06:52 PM

Hi.. I was looking at the Pretty RJ site once again.. and was watching the little banner you have created at the top of the page.. with the changing pictures which so happen to be screen shots off the server.. i was just wondering how one might create somthing like that.. What code would need to be enter where the images would need to be placed etc... Im not a pro.. but i know all the basics of Html so.. i think i can understand the explainations given if anyone is willing to give one.. thx.. alot... cya guys on server soon happy.gif

Posted by: TheLizardKing Dec 19 2003, 01:35 AM

CODE

function OutputBanner() {
   if ($handle = opendir('./images/banners/')) {
       while (false !== ($file = readdir($handle))) {
           if ($file != '.' && $file != '..') {
               $file_array[] = $file;
           }
       }
   closedir($handle);
   }
   return $file_array[array_rand($file_array)];
}


A php function, simply put it enters the directory in the opendir function and copies all file names not . or .. into $file_array[] it then simply returns a random array value consistong on "./images/banners/FILENAME.FILEEXTENSION"

Posted by: DarkSykes Dec 19 2003, 02:51 PM

Anyone care to elaberate just a tad?

Posted by: InfiniteWarrior Dec 19 2003, 05:04 PM

Very loosely translated, I think it means that you first have to be running a PHP site (like this one). Create a directory for the various images you want to use, place your images there and then use the code he's provided to call them randomly on the PHP-driven page. (Programmers. rolleyes.gif)

If you don't have PHP, there are also many javascript snippets and CGI programs that will allow you to rotate images on a page. They're just not nearly as clean or efficient.

I never see those banners at RJ myself, as they are being gobbled up by an ad blocker. I'll have to remember to turn that off one day and take a gander.

Posted by: TheBeast Dec 19 2003, 07:05 PM

One other way to do it... in a PHP page or not (you have to use a 'dynamic' web page language though) is this:

- Name your screenshot all like this

topbanner1.jpg
topbanner2.jpg
topbanner3.jpg
topbanner4.jpg
etc...

- Then with a 'random' function create a number that is between 0 and the last screenshot you have
- Make the filename with the random number (for example: topbanner56.jpg)
- And use a simple IMG HTML tag with the filename as a variable.

Pro
- Faster than Liz's function (I think)

Cons
- You have to change the code everytime you add new screenshots

- Beast

Posted by: DarkSykes Dec 20 2003, 01:14 AM

i understand a lil of what ur saying but i dont know what function to use in the style sheet.. i dont wanna take up anymore of u guys time asking questions.. cuz i know someones probably annoyed that i havnt figured it out yet.. sad.gif i suppose its not meant to be.. Thanks for having patience with me.. and.. offering ur help much appreciated.. sad.gif

Posted by: TheLizardKing Dec 21 2003, 12:31 AM

well HMM, i suppose the first question we should ask you is do you have PHP on your site? You can test by making a file called somethingstupid.php and inside typing this

CODE

<?php phpinfo(); ?>


if something pops up that looks completely different from what you've enetered, you have php. If you know you don't have php find out if you have perl or... well thats all I remember for the serverside languages in that case we are gonna have to use javascript and WOOO doggy you don't want to do that.

Posted by: DarkSykes Dec 21 2003, 10:41 PM

no no php.. wink.gif unsure.gif sad.gif

Posted by: TheLizardKing Dec 25 2003, 01:04 AM

well then you will have to try to get php, use perl (if you have it) or use javascript, the last two options i have little to no experiance with. sorry sad.gif

Posted by: InfiniteWarrior Dec 29 2003, 12:27 AM

Hey, Sykes. Here's a little JS you can try. Pretty clean; works well. This one actually rotates the images w/o a refresh of the page. Not sure if that's what you want. But, if you want to give it a try, put the following in the header of your page:

CODE
<script LANGUAGE="JavaScript" TYPE="text/javascript">
<!--


gImages = new Array(gNumberOfImages);
gImages[0] = "image_path/image1.gif";
gImages[1] = "image_path/image2.gif";
gImages[2] = "image_path/image3.gif";

function canManipulateImages() {
if (document.images)
 return true;
else
 return false;
}
function loadSlide(imageURL) {
if (gImageCapableBrowser) {
 document.slide.src = imageURL;
 return false;
}
else {
 return true;
}
}
function nextSlide() {
gCurrentImage = (gCurrentImage + 1) % gNumberOfImages;
loadSlide(gImages[gCurrentImage]);gSlideshowInterval = 5;
gNumberOfImages = 3;
}
gImageCapableBrowser = canManipulateImages();
gCurrentImage = 0;
setInterval("nextSlide()",gSlideshowInterval * 1000);
// -->
</SCRIPT>


Put this where you want the images to appear:

CODE
<IMG SRC="image_path/image.gif" BORDER=0 ALT="" NAME="slide">


If you want to raise or lower the no. of images you use, change "gNumberOfImages" to the number you want. To change the speed, play with "gSlideshowInterval".

Posted by: DarkSykes Dec 29 2003, 09:25 AM

Thank you ... So kind.. happy.gif Hopfully another one of you angels can solve the problem i posted on the jedi help desk.. wub.gif wub.gif

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (WDYL-WTN Release)