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.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: php selecting multiple stylesheets
am 08.02.2010 05:45:34 von Paul M Foster
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):
// Top of page
session_start();
if ($_SESSION['stylesheet'] == 'enlarged_print')
$css = 'enlarged_print.css';
else
...
?>
....
....
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: php selecting multiple stylesheets
am 08.02.2010 06:43:25 von Trevor Gryffyn
You could use PHP and cookies (session variables are only useful until the
browser is closed, so it's not as persistant as it sounds like you may
want).
You could also have a system where users log in and they can save their
preferences on their user account settings.
What you may also look into is using Javascript (which can also set and
retrieve cookies) and with a good Javascript library like jQuery, it
should be relatively easy to dynamically switch style sheets.
Here's an example of a jQuery based stylesheet switcher:
http://www.kelvinluck.com/assets/jquery/styleswitch/toggle.h tml
Click the styles1, styles2 and styles3 links.
Also, there are JS scripts for adjusting font size, so you may not need a
completely different stylesheet. But it would mean having well designed
HTML that will scale nicely with the font change. Or you could just
have a different stylesheet, as you mentioned, so you know it will look
exactly how you want. You can see an example of a font size JS here:
http://www.joomla-beez.com/
Keep clicking the links in the upper right and you can continue to increase
or decrease the size quite a bit, not just one step.
I know this is a PHP list but I think a client side script may work better
in this case.
-TG
----- Original Message -----
From: David Mehler
To: php-general@lists.php.net
Date: Sun, 7 Feb 2010 23:20:18 -0500
Subject: [PHP] php selecting multiple stylesheets
> 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.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Sun, 2010-02-07 at 23:45 -0500, Paul M Foster wrote:
> 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):
>
>
> // Top of page
> session_start();
>
> if ($_SESSION['stylesheet'] == 'enlarged_print')
> $css = 'enlarged_print.css';
> else
> ...
>
> ?>
>
> ...
>
> ...
>
>
> Paul
>
> --
> Paul M. Foster
>
I'm doing this on my own site, and it works like this:
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.
in CSS there is also the concept of 'alternate stylesheets' build in. A page can
basically specify as many stylesheets as it wants where one is default and all others are 'alternate'. The browser will then offer menu entries for the user to choose from. Ie in firefox you can choose the style from the menu at: View -> Page Style -> ...
Here's how it works in detail: http://www.w3.org/Style/Examples/007/alternatives (note that this site also has alternate styles available)
PHP could be used to define the default style sheet on a per user/application setting basis...
stephan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Mon, 2010-02-08 at 11:18 +0100, Stephan Ebelt wrote:
> 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.
>
>
> in CSS there is also the concept of 'alternate stylesheets' build in. A page can
> basically specify as many stylesheets as it wants where one is default and all others are 'alternate'. The browser will then offer menu entries for the user to choose from. Ie in firefox you can choose the style from the menu at: View -> Page Style -> ...
>
> Here's how it works in detail: http://www.w3.org/Style/Examples/007/alternatives (note that this site also has alternate styles available)
>
> PHP could be used to define the default style sheet on a per user/application setting basis...
>
> stephan
>
>
>
The only problem relying only on this method is that not all browsers
are compatible with it, and of those that are, none remember the choice
a user makes from page to page, so they'd have to reselect it upon each
page visit
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-pf3Xp5Df1OrWaEYxAGSS--
Re: php selecting multiple stylesheets
am 08.02.2010 14:29:29 von Michael Peters
TG wrote:
> You could use PHP and cookies (session variables are only useful until the
> browser is closed, so it's not as persistant as it sounds like you may
> want).
Persistent sessions are possible.
The way I'm doing it in the CMS I am working on is via GET which saves
selection in session.
I can't use a selector because I tailor the web page to the style sheet
and some of them require different page design (IE search bar in aside
opposed to header)
I don't use persistent sessions, but session is kept in cookie and you
can configure it to be a persistent cookie if you want.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: php selecting multiple stylesheets
am 08.02.2010 14:45:12 von Al
On 2/7/2010 11:20 PM, 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.
Dealing with style sheet caching by all the different browsers and the user's
settings for them is the big problem.
I'd suggest this: Use the sessions buffer for simplicity. And, link your
complete [all the selectors] default css file in the header.
Then, include ONLY the selectors needed to render the special selectors in the
html's header style block. These selectors will override those in the css file.
Now, simply modify the selectors here when you return the page. Far as I know,
all browsers honor revised styles when they are in the page html header.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: php selecting multiple stylesheets
am 08.02.2010 16:00:47 von TedD
At 11:20 PM -0500 2/7/10, 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.
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
Try this:
http://sperling.com/examples/styleswitch1/
As far as zooming text size, most browsers are capable of this. Just
make your site zoom-cooperative, such as:
http://sperling.com/examples/zoom/
As far as making things high contrast, why not choose colors that are
right the first time? Try this:
http://webbytedd.com/c/access-color/
As far as making all of this persistent, look to using Cookies.
> At 11:20 PM -0500 2/7/10, 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.
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> Try this:
>
> http://sperling.com/examples/styleswitch1/
>
> As far as zooming text size, most browsers are capable of this. Just
> make your site zoom-cooperative, such as:
>
> http://sperling.com/examples/zoom/
>
> As far as making things high contrast, why not choose colors that are
> right the first time? Try this:
>
> http://webbytedd.com/c/access-color/
>
> As far as making all of this persistent, look to using Cookies.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
There is a good reason for having different stylesheets that use
differing colour systems. For example, some people with learning
difficulties benefit from yellow text on blue backgrounds, as apparently
those colours together are better at capturing a users attention for
longer durations. This is often coupled with other layout changes such
as narrower width text blocks to aid readability.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-ixXL2JqO9W4BrlPkbgv2--
Re: php selecting multiple stylesheets
am 08.02.2010 18:09:12 von Michael Peters
Ashley Sheridan wrote:
>
>
> There is a good reason for having different stylesheets that use
> differing colour systems. For example, some people with learning
> difficulties benefit from yellow text on blue backgrounds, as apparently
> those colours together are better at capturing a users attention for
> longer durations. This is often coupled with other layout changes such
> as narrower width text blocks to aid readability.
It's also not a bad idea to have a layout designed for small computer
screens, 1024x is what most of my style sheets are designed for but one
is designed for 800x.
There are still some people with small displays, and horizontal
scrolling really sucks.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: php selecting multiple stylesheets
am 08.02.2010 21:22:34 von Stephan Ebelt
On Mon, Feb 08, 2010 at 10:22:07AM +0000, Ashley Sheridan wrote:
[...]
> > in CSS there is also the concept of 'alternate stylesheets' build in. A
> > page can basically specify as many stylesheets as it wants where one is
> > default and all others are 'alternate'. The browser will then offer menu
> > entries for the user to choose from. Ie in firefox you can choose the style
> > from the menu at: View -> Page Style -> ...
> >
> > Here's how it works in detail:
> > http://www.w3.org/Style/Examples/007/alternatives (note that this site also
> > has alternate styles available)
> >
> > PHP could be used to define the default style sheet on a per
> > user/application setting basis...
> >
> > stephan
> >
> >
> >
>
>
> The only problem relying only on this method is that not all browsers
> are compatible with it, and of those that are, none remember the choice
> a user makes from page to page, so they'd have to reselect it upon each
> page visit
yes, it can't be relied on it.
I made the primary method for configuring the theme an user setting in the
application. This setting is very easy to implement as it just defines the
theme that is shown first and without 'alternate' attribute in each page header
(unaware browsers will take this too as its the standard syntax). All other
themes are then added in a row with the 'alternate' attribute set. So that all
themes available in the program are always advertized to the browser.
The goody is that users can quickly change the theme if they feel a need to do
so right in the heat of the moment. It wont permanently modify their setting.
Its perfect to just try themes at any place in the application or to do
something specific with a different theme... the page doesn't reload (in
firefox), so one can even change the theme in the middle of filling a form...
very flexible.
As far as I've seen unaware browsers just ignore the 'alternate' lines, so
there's no harm.
stephan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: php selecting multiple stylesheets
am 09.02.2010 04:53:01 von David Mehler
Hello Everyone,
Thank you for the various positions and suggestions.
I'm going for either cookies or sessions, your examples have given me
much to check. For this situation I should probably have mentioned I
need to keep this as simple as possible, so features like a user login
system and cms i'd prefer to avoid for these circumstances.
I am going to implement browser detection as my user's will use both
firefox and IE probably ie6 through 8.
For firefox you can use view, page style to switch stylesheets, but in
ie if there's no drop down box or links on the page for switching
styles it can't do it, is that correct?
Thank you all, i'm going to look at the many links sent and keep at
this until i get it.
Dave.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php