Home  |  Linux  | Mysql  | PHP  | XML
From:Paul M Foster Date:Mon Feb  8 04:45:34 2010
Subject:Re: php selecting multiple stylesheets
On Sun, Feb 07, 2010 at 11:20:18PM -0500, David Mehler wrote:

> Hello,
> I'm trying to set up a web site. This site has multiple stylesheets,
> one default stylesheet that should be used if the other is not chosen.
> The second is a high contrast stylesheet and can be selected by user's
> who need it. I'm also thinking of adding two more for smaller and
> larger font selections. My issue is I want the high contrast sheet to
> be used on all subsequent pages and on subsequent visits to the site
> by user's who have selected it. I thought of using php with this and
> cookies. I'm using php5 and would appreciate any suggestions, googling
> has shown some examples, but none are working.
> Thanks.
> Dave.

There are two main PHP-centric solutions to this. First is cookies (as
you described) and the second is using the $_SESSION global array.

Doing this is relatively straightforward, so if it's not working for
you, I see two possibilities: 1) You're not actually doing it right. 2)
The users isn't pressing the "Reload" button after selecting the
stylesheet. (My experience has been that simply redisplaying a page will
not clear the cached CSS styles for that page. You must hit the "Reload"
button. In fact, in some cases, like offices with caching webservers or
proxies, an admin will have to be called in to clear the cache on the
proxy/server as well.)

You should be able to do something like this (I'm using SESSION
variables because cookies are more complicated):

<?php
// Top of page
session_start();

if ($_SESSION['stylesheet'] == 'enlarged_print')
$css = 'enlarged_print.css';
else
...

?>
<html>
...
<link href="<?php echo $css; ?>" rel="stylesheet" type="text/css"/>
...
</html>

Paul

--
Paul M. Foster
Navigate in group php.general at sever news.php.net
Previous Next


Your recent visits
cvs: peardoc /en/package/xml/xml-serializer/xml-unserializer options.xml
cvs: peardoc /en/package/fileformats/contact-vcard-build intro.xml usage.xml
LMPX.COM :: Linux, Mysql, Php, Xml
Re: [PHP] Re: PHP in HTML code
cvs: pecl /apc apc_main.c apc_signal.c



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants