Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-09-2007, 11:15 PM
skilletsteve skilletsteve is offline
Learning Programmer
 
Join Date: Aug 2006
Posts: 45
Rep Power: 9
skilletsteve is on a distinguished road
Default Question: Dynamic Styles With PHP

Hey,
I'm just wondering if it would be possible to make dynamic stylesheets on a php document.
example: have several style sheets (style1.css, style2.css, style3.css, etc...) and have the PHP document randomly load a different one each time, to keep the page fresh to the visitor.

If it is possible, any pointers on how to do it?

thanks a lot
-Steve
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 03-10-2007, 12:55 PM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Its possible, Joomla! does it, but I have no idea how its done
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-11-2007, 05:17 AM
Jordan's Avatar   
Jordan Jordan is online now
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,232
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Yes, this is possible. The theme I have in Joomla! does it (CodeCall - Home - look at the color buttons in top). It is done using PHP. If the user selects the #default tag it loads one color style sheet named default.css.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-31-2007, 05:03 PM
Centreri's Avatar   
Centreri Centreri is offline
Newbie
 
Join Date: Mar 2007
Location: NY, Queens, Forest Hills.
Age: 16
Posts: 28
Rep Power: 7
Centreri is on a distinguished road
Send a message via AIM to Centreri Send a message via MSN to Centreri Send a message via Yahoo to Centreri Send a message via Skype™ to Centreri
Default

Very easy to do and many ways to do it. The simplest one is to make a variable equal to a random number between 1 and number of files you have, and then, in the section where you link to the css file, make it load a css file depending on that number.

Code:
<?php
$stylevar = rand(1, 5);
?>
<link rel="stylesheet" type="text/css" href="style<?php echo $stylevar; ?>.css" />
That would be an easy way to do it if your styles were named style1.css, style2.css, etc. Or you can just make an if/else statement that if $stylevar is 1, you use echo or print to use whatever style you want.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-31-2007, 05:06 PM
skilletsteve skilletsteve is offline
Learning Programmer
 
Join Date: Aug 2006
Posts: 45
Rep Power: 9
skilletsteve is on a distinguished road
Default

Thank you very much. This seems to work quite well.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 03-31-2007, 10:35 PM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

I actually had to implement this into one of my designs for a customer, I found this which worked great.

Dynamic Drive DHTML Scripts- Style Sheet Switcher (v1.1)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 4 end of life announcement Jordan Programming News 4 08-30-2007 10:55 AM
Question: free webhosting with PHP, SMTP, and at least one SQL database skilletsteve Hosting and Registrars 5 12-08-2006 05:36 AM


All times are GMT -5. The time now is 05:12 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads