SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Multiple CSS Files
-
May 12, 2003, 16:45 #1
- Join Date
- Apr 2003
- Posts
- 208
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Multiple CSS Files
JUST come up with this concept now
How would I be able to do it so; every time the website refreshes it loads up a new .css file.
For instance, someone goes to "the site" and they'll see a blue layout because it's loaded up the blue.css file. But then the user refreshes and it loads up the pink layout because it loaded up the pink.css file etc etc.
For say a maximum of 10 css files or however many css files are in the css/ directory.
Anyone got any ideas, links to help, or help themselves?
Regards,
Chris
-
May 12, 2003, 17:28 #2
- Join Date
- Oct 2001
- Location
- Bay City, Oregon
- Posts
- 715
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ASSuming you don't want to keep track of the CSS file via cookie/session, you could set up a little code to randomly select which CSS file is written to the head of the page you are serving.
-
May 13, 2003, 05:00 #3
- Join Date
- Jan 2002
- Location
- Canada
- Posts
- 6,364
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
have a file called css.php, with this:
PHP Code:$css = array();
$css[1] = ".text{ font-family...... }";
$css[2] = "more stuff";
if (isset($_COOKIE['css']) && $_COOKIE['css'] < count($css))
{
echo $css[$_COOKIE['css']];
$new = $_COOKIE['css'] + 1;
set_cookie("css", $new, time() + * 3600 * 24 * 365
}
else
{
echo $css[1];
setcookie("css", "1", time() + 3600 * 24 * 365);
}
It'll go through them.- Nathan
-
May 13, 2003, 08:07 #4
- Join Date
- Aug 2001
- Location
- Amsterdam
- Posts
- 788
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
how to do it with css files
Funny I didn't think of this but now you say it it really sounds nice...
lets see
PHP Code:$cssfiles = array();
$handle =opendir($directory); // open the directory
while ($file = readdir($handle))
{
if (($file != ".") && ($file != "..") )
{
$cssfiles[$i] = $file;
$i++;
}
// now all the css files are in 1 array
closedir($handle); // closedir
reset($cssfiles);
srand ((float)microtime()*1000000); // get random
shuffle ($cssfiles); //lets shuffle the deck
// now just use $cssfiles[0] cause it's different everytime
echo $cssfiles[0];
the neigbours (free) WIFI makes it just a little more fun
-
May 13, 2003, 09:31 #5
- Join Date
- Jan 2002
- Location
- Canada
- Posts
- 6,364
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's different, but it's not ordered, so you could end up having the same ones more than once in a row if there are only 2 or 3.
However adding:
PHP Code:$cssfiles = array();
$handle =opendir($directory); // open the directory
while ($file = readdir($handle))
{
if (($file != "." ) && ($file != ".." ) )
{
$cssfiles[$i] = $file;
$i++;
}
Regards,
Someonewhois
(P.S. Thanks whoever gave me 14 reputation marks for this post)
- Nathan
-
May 13, 2003, 09:54 #6
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:while ($file = readdir($handle))
PHP Code:while (false !== ($file = readdir($handle)))
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
May 14, 2003, 01:24 #7
- Join Date
- Aug 2001
- Location
- Amsterdam
- Posts
- 788
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by cyborg from dh
otherwise it don't work!!!!the neigbours (free) WIFI makes it just a little more fun
Bookmarks