Newest Site/Random Site Button Script Thingy?
-
- Events Staffer
- Posts: 3072
- Joined: Thu Aug 07, 2014 3:15 pm
- Location: North Carolina, USA
- Contact:
Newest Site/Random Site Button Script Thingy?
I've noticed a lot of Amassment folks have a "newest site" and "random site" thing that displays button links of their sites. How is this accomplished? (I've been Googling it, but I don't think I'm using the right terminology for it xD)
Re: Newest Site/Random Site Button Script Thingy?
You can use a rotation script similar to the ones used on button exchanges for the random site and the latest would be updated manually. I use JS for Starlight and I'm planning to add a php version to AzureLight.net. Of the two, I recommend JS for actual rotations since not everyone runs php, and php for personal stuff since it won't be used by anyone else anyway. I can email you the codes if you want.
-
- Events Staffer
- Posts: 3072
- Joined: Thu Aug 07, 2014 3:15 pm
- Location: North Carolina, USA
- Contact:
Re: Newest Site/Random Site Button Script Thingy?
That would be great! :D (lol I thought all the button rotations were done by hand somehow...#noobproblems)
Re: Newest Site/Random Site Button Script Thingy?
I emailed the code. :D
Let's say you have 25 sites in this example. You would put the html belonging to each button inside each div and include the file as you would any php include. Notice that the codes are the same with different numbers. On top we make all 25 divs invisible, then we choose a random number from 1 to 25 and make only that div visible.
If you had 50 sites then instead of 25 codes you'd need 50. First the invisible div code, then the random number selector from 1 to 50 and the 50 divs. Likewise if you had 10 sites, you'd have to modify the max number to 10. You can keep the extra empty divs that you're not using in the file for later use, but make sure that the random selector only goes up to the number of divs you're using without any empty divs in the middle.
So if you had 15 sites, you'd occupy divs 1 to 15 with the button html inside each div and set the random selector to $totaldiv = mt_rand(1,15); You can use this, not only for buttons, but for anything you want to randomize inside the divs. If you want to show the divs between text/images, (without sending the next thing to a new line) you can replace "block" with "inline" :)
Edit: I added a page about this to my site with PHP and JS examples: random elements
Let's say you have 25 sites in this example. You would put the html belonging to each button inside each div and include the file as you would any php include. Notice that the codes are the same with different numbers. On top we make all 25 divs invisible, then we choose a random number from 1 to 25 and make only that div visible.
If you had 50 sites then instead of 25 codes you'd need 50. First the invisible div code, then the random number selector from 1 to 50 and the 50 divs. Likewise if you had 10 sites, you'd have to modify the max number to 10. You can keep the extra empty divs that you're not using in the file for later use, but make sure that the random selector only goes up to the number of divs you're using without any empty divs in the middle.
So if you had 15 sites, you'd occupy divs 1 to 15 with the button html inside each div and set the random selector to $totaldiv = mt_rand(1,15); You can use this, not only for buttons, but for anything you want to randomize inside the divs. If you want to show the divs between text/images, (without sending the next thing to a new line) you can replace "block" with "inline" :)
Edit: I added a page about this to my site with PHP and JS examples: random elements