PHP Style Sheet Switcher

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

Re: PHP Style Sheet Switcher

Post by katea »

OK, this works great but for one small probem.

I can change the stylesheets no problem, but once I've loaded a stylsheet, then choose another, I can't go back to the stylesheet chosen before unless I reset to default.....

Kinda hard to explain, but let me run you through my process:

4 stylesheets .... Let's call them default, red, white and blue.

Clcik on red ... Great
Click on Blue ... Great
Click on White ... Great ...
Click back on Blue ... Doesn't work!

Click on default, then click back on Blue .. Great

It seems that once one stylesheet is loaded, it doesn't want to load it for a second time unless I click the default, then it's OK.

Default has obviously got a refresh or something, but the others seem to cache and hide.

Any way around this?

Thanks
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

Re: PHP Style Sheet Switcher

Post by katea »

OK, this is fixed if you change the time from 86400 to 1 ....

Although, this not makes the cookie pointless doesn't it?

It would be great to have it remember it for the next time the user visits, but it's important for me to have an instant change.

Any other way of working this do you think?
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

Re: PHP Style Sheet Switcher

Post by katea »

Forget it, this does not work in opera or IE6.

That's a complete let down... OK, let's look for another solution.
katea
Forum Members
Forum Members
Posts: 116
Joined: Wed Jun 10, 2009 12:25 am

Re: PHP Style Sheet Switcher

Post by katea »

Jquery is the way!

Works flawlessly in all browsers!

http://www.kelvinluck.com/2006/05/switch-stylesheets-with-jquery/
Airidas
Forum Members
Forum Members
Posts: 46
Joined: Sun Mar 21, 2010 1:32 pm

Re: PHP Style Sheet Switcher

Post by Airidas »

Hi katea, can you give more instruction how to add jquery to cms made simple?
Im a litle fresh, can you give some instructions?

Many thanks.
cyberman

Re: PHP Style Sheet Switcher

Post by cyberman »

JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: PHP Style Sheet Switcher

Post by JM6891 »

Hi All,

I'm using the original method of style switcher, as described on the first page of this thread, however I've run into a problem now that my site has been transferred to a different server.

My development server spec:

PHP5.2.10
Linux
Apache 2.0

On the above server, my PHP style switcher worked fine.

Live server spec:

PHP4.3.9
Linux
Apache 2.0

On the above server, my switcher only loads the default style. When I click on the different links to load my 'medium' stylesheet, or 'large' stylesheet, the default stylesheet remains.

Is this a problem with the server or cookies perhaps? I am a complete noob to PHP and fairly new to CMSMS so any help anyone can give would be great.

Thanks in advance.
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: PHP Style Sheet Switcher

Post by JM6891 »

Actually, I just doubled checked my switcher.php and I hadn't amended the domain for the cookie. My bad!
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: PHP Style Sheet Switcher

Post by JohnnyB »

JM6891 wrote:Actually, I just doubled checked my switcher.php and I hadn't amended the domain for the cookie. My bad!
That was going to be my question :)
I like using the original because it isn't dependent upon javascript support.  I'm using it here for high contrast and font sizes:

remove the spaces (don't want it indexed from here ;)
www [dot] t h e  i r i s [dot] org  (need the www. )
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
sp
New Member
New Member
Posts: 5
Joined: Sun Aug 08, 2010 4:17 pm

Re: PHP Style Sheet Switcher

Post by sp »

hey, i have added the styles witcher to a site. im using it to switching three different font-types default,large and xlarge.

so now i have the same problem like katea. you could switch to  large, then to xlarge.
but then when you click the large button again the style won't switch!
you have to switch to default first to go to large again.

mww i saw your theiris site, there it works right.
whats the difference?


sp
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: PHP Style Sheet Switcher

Post by JohnnyB »

sp - I think this thread has a couple different versions posted.... Do you know if you are using the one I am using?  do you have a link to your site? you can PM me.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Post Reply

Return to “Tips and Tricks”