plugin post

Purpose
One of the best things about using WordPress is the ability to skin your site at will by choosing a new theme. There are theme switcher plugins available which allow your website visitors to skin your site with their choice of themes, selected from the stylesheets currently in your /themes/ directory.

I only have three themes in my /themes/ directory: Classic, Default, and K2. When I skin my site, I do it with a style, an alternate stylesheet for K2. So all the nifty theme switcher programs don’t work for me.

I wrote this plugin to be the K2 equivalent of a theme switcher.

Usage
This plugin will place either a dropdown menu (strictly HTML) or an unordered list (uses some Javascript) of the styles you select into your sidebar.

You select the type of display (menu or list) and the styles to display from the K2 Style Switcher administration panel, found in the Presentation menu.

This plugin also takes over the default K2 Scheme option. You will need to use the K2 Style Switcher panel to set your default style and footer display.

To display the style switcher, simply place the following code in your sidebar:
<?php k2ss_sidebar(); ?>

Installation

K2 must be installed in ‘/themes/k2/’ and selected as the current theme.
Please do not attempt installation if this is not the case.

To install the K2 Style Switcher, follow these steps:

  1. Download style-switcher.zip.
  2. Extract style-switcher.php to your /wp-content/plugins/ directory.
  3. Activate the plugin in Plugins Management.

Assuming K2 is installed, and that K2 is the currently selected theme, you should now see the K2 Style Switcher panel in your Presentation menu.

Configuration
The first time you visit your new administration panel, all options will be blank.

The first option controls the way the sidebar module displays the styles list.

Unordered List
Displays a list of links. Requires javascript to work, but the javascript is only added to your page if this option is selected.

Dropdown Menu
Displays a form for your visitors to use. This option is strictly HTML.

The second option displays all the styles currently available in your /k2/styles/ directory. Select the styles you want website visitors to be able to use.

‘K2 Scheme’ (from the ‘K2 Options’ tab) had to be disabled (set to ‘No Scheme’) for the plugin to work as intended. That means no default style and no footer, so the next two K2 Style Switcher options replace ‘K2 Scheme’.

The third option sets the style that visitors will see upon first landing on your page. Once they select a style, they will see that style instead.

The fourth option replaces the style info display in your footer. The footer display is by far the most complicated area of the plugin to configure.

Because I was tired of editing my footer file directly, this is intended to replace the entire footer. You can put whatever you like at the bottom of your pages using this option. The only limitation is that you cannot run php code directly.

The tags from the ‘K2 Options’ page are all available. They will display the stylesheet information for the currently displayed style.

Formatting to be used for displaying the style info. Use: %style% for style name, %stylelink% for the style’s homepage, %author% for author, %site% for author’s site, %version% for version and %comments% for style comments.

Additional tags:

%stylefolderpath% The folder URI of the currently displayed style.

I use it on my personal blog to change the “ONE” image in my footer. There is a different ‘one.jpg’ in each style folder, and I call it in my footer using
<img src="%stylefolderpath%/one.jpg">

%bloginfoname% Name of the blog, as set in Options.

This is the name that would normally display in your header.

%bloginfoversion% WordPress version.

%k2infoversion% K2 version.

%podpressversion% podPress version, if installed.

The podPress plugin usually puts a footer at the bottom of the page. You can’t really control placement or styling, and I had begun hardcoding the plugin so that it would display the footer the way I wanted. Way too complicated.

Be sure to disable the podPress footer in podPress/General Settings.

%templatepath% The web path to K2.

Useful if you want to use one of the stock K2 images in your footer.

Here’s the code for the transparent.gif, found in /k2/images/:
<img src="%templatepath%/images/transparent.gif" />

%rssentries% Outputs the URI for a ‘RSS Entries’ link.

%rsscomments% Outputs the URI for a ‘RSS Comments’ link.

Here’s the code that displays the footer you see on this site: footer-code.txt.

You’ll note the use of line breaks, instead of paragraph tags. K2 Style Switcher automatically outputs an opening and closing paragraph tag.

Style
You’ll need to add a few lines of css to each stylesheet to be displayed.

First, you need to make sure the default footer doesn’t display:
#footer { display: none; }

Then, you need to make sure that your new footer displays as intended:
#k2ss_footer { text-align: center; }
#k2ss_footer a { color: blue; }
#k2ss_footer a:hover { color: silver; }

You’ll want to change this to your own style preferences. It’s probably easiest to rename #footer to #k2ss_footer, thus preserving the existing css.

If your footer isn’t displaying the way the old one did, you probably need to add the #footer css from /k2/style.css to your #k2ss_footer css.

If you opt to use the unordered list to display your sidebar, the class .k2ss_selected can be styled to highlight the currently selected style in the list.
.k2ss_selected { border-left: 1px dashed #666; }

Have fun with it, and please don’t hesitate to ask questions :)

0 Responses to “plugin post”


  1. No Comments

Leave a Reply