PhotoDune

Wordpress Style Switcher

1259 posts
  • Envato Staff
  • Reviewer
  • Community Moderator
  • United Kingdom
  • Sold between 10 000 and 50 000 dollars
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Gold Mo Grower
  • Author had a File in an Envato Bundle
+13 more
ChristineWilde moderator says

Hi guys and gals,

How can I create a front end style switcher for my Wordpress theme? I got what I want in my theme options panel but I need it to work on the front as well so potential buyers can change the graphics and styles.

There are quite a few things that can be changed, I don’t have just 5 style sheets named blue.css, red.css, etc.

The potential client can change the background colour, background gradient, background pattern and content colour.

Something similar to what Kriesi has created on his latest theme. I think this is the only way viewers are going to be able to change the styles.

Any help would be awesome!

629 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • United States
VagrantRadio says

Here is how I do mine on my Illuminati theme using jquery.cookie.js

$(document).ready(function() {
  $("a").click(function() {
    $("link").attr("href",$(this).attr('rel'));
    $.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'});
    return false;
 });
}); 

Then just put your stylesheets in the links they click.

<a href="#" rel="yourstyle.css">Dark Blue</a>
1915 posts Do the Needful
  • Envato Staff
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Support Staff
  • United States
  • Author had a Free File of the Month
  • Microlancer Beta Tester
  • Beta Tester
  • Interviewed on the Envato Notes blog
+7 more
JamiGibbs support says

I use the Dynamic Drive style switcher:

http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm

You’ll have to add some styling to make it look decent but it’s a great no-frills option.

1259 posts
  • Envato Staff
  • Reviewer
  • Community Moderator
  • United Kingdom
  • Sold between 10 000 and 50 000 dollars
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Gold Mo Grower
  • Author had a File in an Envato Bundle
+13 more
ChristineWilde moderator says

So am I going to have to put each style option in it’s own style sheet for this to work?

My theme allows the user to change each element separately.

For example:

Unlimited Background Colours – This needs to be a hex code added by the user

5 Background Patterns – 5 different images used

18 Background Gradients – 18 different images used

2 Content Colour – 2 different style sheets

In the theme options panel the name of the colour determines the images used in the background. I only have the main style sheet, dark and light content style sheets and some styles in the header ( used for the theme options ).

1915 posts Do the Needful
  • Envato Staff
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Support Staff
  • United States
  • Author had a Free File of the Month
  • Microlancer Beta Tester
  • Beta Tester
  • Interviewed on the Envato Notes blog
+7 more
JamiGibbs support says
So am I going to have to put each style option in it’s own style sheet for this to work?

My theme allows the user to change each element separately.

For example:

Unlimited Background Colours – This needs to be a hex code added by the user

5 Background Patterns – 5 different images used

18 Background Gradients – 18 different images used

2 Content Colour – 2 different style sheets

In the theme options panel the name of the colour determines the images used in the background. I only have the main style sheet, dark and light content style sheets and some styles in the header ( used for the theme options ).

Oh boy.. yeah. That’s a whole different can of worms. For demonstration purposes, you’re probably going to need to create a few different color combination style sheets for your buyers to try out. Otherwise, I don’t know of a way to do it short of providing a test user login information to the WP admin panel.

1259 posts
  • Envato Staff
  • Reviewer
  • Community Moderator
  • United Kingdom
  • Sold between 10 000 and 50 000 dollars
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Gold Mo Grower
  • Author had a File in an Envato Bundle
+13 more
ChristineWilde moderator says

@JamiGibbs Yeah I thought it was going to be a tad more difficult then I thought. I can narrow the background colours down to just black, white and grey. Then create style sheets for each background image. As this is just going to be for the preview it shouldn’t matter if it uses many style sheets, should it?

765 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • Serbia
  • Has been a member for 4-5 years
rvision_ says
So am I going to have to put each style option in it’s own style sheet for this to work?

My theme allows the user to change each element separately.

For example:

Unlimited Background Colours – This needs to be a hex code added by the user

5 Background Patterns – 5 different images used

18 Background Gradients – 18 different images used

2 Content Colour – 2 different style sheets

In the theme options panel the name of the colour determines the images used in the background. I only have the main style sheet, dark and light content style sheets and some styles in the header ( used for the theme options ).

Only way I see is to serialize all this data in the cookie and use it on the php side to set the style.

6 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 10 000 and 50 000 dollars
  • United States
mbsatunc says

I am in need of some help. I have a style switcher in place. Everything is working great, but Cufon is not setting the colors of the new stylesheet until you either a) mouse over menu items (only fixes menu items) or b) you head to a new page (or re-enter the current address in the address bar). Any help is greatly appreciated. Here is the url: http://practicefieldadv.com/wp/squared3/grey

765 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • Serbia
  • Has been a member for 4-5 years
rvision_ says
I am in need of some help. I have a style switcher in place. Everything is working great, but Cufon is not setting the colors of the new stylesheet until you either a) mouse over menu items (only fixes menu items) or b) you head to a new page (or re-enter the current address in the address bar). Any help is greatly appreciated. Here is the url: http://practicefieldadv.com/wp/squared3/grey

Cufon.Refresh(); might help?

6 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 10 000 and 50 000 dollars
  • United States
mbsatunc says
I am in need of some help. I have a style switcher in place. Everything is working great, but Cufon is not setting the colors of the new stylesheet until you either a) mouse over menu items (only fixes menu items) or b) you head to a new page (or re-enter the current address in the address bar). Any help is greatly appreciated. Here is the url: http://practicefieldadv.com/wp/squared3/grey
Cufon.Refresh(); might help?

Thanks, but no luck. I had tried that earlier. It actually causes the Cufon replacement to stop entirely.

by
by
by
by
by