Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User chooses style sheet

Status
Not open for further replies.

IndyGill

Technical User
Jan 15, 2001
191
GB
Hi

I have been asked to take on a web project and one of the aspects of the project is to allow the user to customise the colours used on the site. So i take it that I would have to create multiple style sheets and from this the user gets to select a relevant style sheet.

Is there any other way to do this? Or I would grateful for any good sample that allow the user to customise the site.

Many thanks in advance
 
what server language are you using -- with php i would have a drop down menu that would set the stylesheet into a session variable which would then be called into the stylesheet tag

Code:
<link href=<? echo &quot;\&quot;$_SESSION['stylesheet']\&quot;&quot; ?> rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>

to set the session i use

session_start();
$stylesheet = &quot;$_GET['style']&quot;;
session_register(&quot;stylesheet&quot;);

where $_GET['style'] is what is passed from the URL

Code:
[URL unfurl="true"]http://www.mysite.com/page.php?style=style1.css[/URL]

now you would set up your dropdown menus with all the same urls except where style=style1.css that would change depending on what style you want called

hope this helps

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
im using asp.net, I thought putting it in a session would be the best way.

Cheers
 
I have just thought, if I did use the session method then I would have to extend the default session timeout on my ISS server. Thus putting more pressure on my server

As the session will only last 20 minutes? And half way through the visit the session may expire and go back to its default value.

Does this mean that I will have to it through teh URL? or how about using a cookie to store the value, so when the user returns to teh site it remembers the users settings?

But to be honest I have also tried to stay away from Cookies, dows anybody have any opinions on this?

Thanks in advance
 
Indy - the session is renewed every time the user navigates to a new page on your site so the session timeout is not the main problem.

As a user, I would hate to set my colors today and have them be gone tomorrow - why even set them? The answer is to store the className in a cookie...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Do the users log into the site? If so, I would store the style name in a database (more permanent than a cookie or session) and then when the user returns to the website & logs in you can retrieve the preferences from the DB and store them in a session.

Like mwolf00 said, each time the user requests a page the timer restarts. So unless they stay at a page for longer than 20 minutes, it won't be a problem. If you think that will be a problem, you can fix it one of two ways. You can force them to log back in after the session times out, or you can increase the session times.

Lastly, you could take an entirely different approach. CSS Zen Garden ( ) uses different links for each style. Create a link with the style included in the URL. For instance ( ). Then use the server side processing (ASP) to add the appropriate line of code to your page. Your visitors could then &quot;bookmark&quot; the appropriate link. (Just as a disclaimer, this last approach is not what I would do).

Good luck.
-Ron

-We are all given the same deck of cards, it's how we play the hand we are dealt which makes us who we are.
 
Darkshadeau

<offTopic>
We are not all given the same deck of cards. Our hand is dealt from the same deck of cards...
</offTopic>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top