Archive for themes

flexible layouts

I stumbled across the Nearly Sprung theme, which is a three column rework of the Almost Spring theme (which I have available in one of the theme options). I loved this one, though. I’ve been keeping my eyes open for a flexible width theme that I liked, and the three column format was just icing on the cake.

I’m still working out whether I want a secondary colour or not, so forgive the flashes that may be appearing on your screen :-D

del.icio.us:flexible layouts  digg:flexible layouts

Comments (1)

general fun with themes

I know I’ve been quiet — it’s been busy at work and lethargy-inducingly humid once I get home. Plus I’ve been working on a new plugin and setting up a phpbb forum (and working on a skin for that: why is it I can never leave well enough alone?). In any case, I worked out a rather convenient way of being able to drop in a new theme and standardize its sidebar pretty quickly. A new theme has a vanilla sidebar which besides not including all my cool perks, most importantly does not include a theme switcher. Meaning that when I install it, if I didn’t add at least the theme switcher hook, a visitor could wind up trapped in that theme. Ugh. At the same time, dropping in a new sidebar got tedious, especially when there were a few cases I added or changed something and had to migrate those changes across the board.

So I came up with this solution, which is working well for me, though it’s not 100% adaptable to everything (it’s best suited for two column formats with sidebar on left or right, although it seems to be okay when the sidebar is the footer, as the latest trend of single column themes is taking hold). It’s a tinker-under-the-hood process, though, so if you’re not comfortable rooting around in your wordpress files, you may want to pass this up. For the rest of you, if this sounds interesting, roll your sleeves up!

First of all in any theme (or most standard ones), there will be a sidebar.php file. In themes set for WordPress 2.0 and onward, these seem to be wrapped in a div with a sidebar id and using a basic ul for formatting. They’re not completely identical, especially older themes seem to have some kind of menu or other class/id in use. Plus, some themes seem to have an annoying format where the first line (I kid you not) in the sidebar.php file is a </div>!! I haven’t dug into this issue deeply enough to determine whether it’s an unfortunate necessity, or crappy formatting. The upshot of all this, though, meant that I couldn’t use my first solution, which was to move a copy of sidebar.php up to the general themes directory and softlink back to it from within each specific theme directory.

What I did instead was isolate the common elements within the wrappers in the sidebar file and yank those out into the general themes directory in a file I called sidebar-contents.php. I then replaced that part of the code with an include file. So for example, my default theme’s sidebar file looks like this:

<div id="sidebar">
<ul>
 
<?php include (TEMPLATEPATH . '/../sidebar-content.php'); ?>
 
</ul>
</div>

And this has been working a treat. Now when I play around with the format of my sidebar, I change items in the included file, and all changes are instantly available to all the themes.

Told you I was a lazy programmer ;-)

del.icio.us:general fun with themes  digg:general fun with themes

Comments (2)

wp-CaTT modifications

I use the wp-CaTT plugin for a simple Technorati hook. All it does is add Technorati links straight off the WordPress categories I choose for each article. I like it because it is simple, focused, and fast. I don’t have to do anything extra — always a bonus, I’m very lazy — to get it to work, and it doesn’t slow down my website either (generally, DreamHost does that just fine all by itself). Other plugins I looked at got all complicated with specialty tags where I’d have to remember not only the syntax, but to do it at all while scribbling my notes down. Or, they had so many (admittedly very impressive) bells and whistles that I simply wasn’t utilizing all of them which always seems a waste. Or worse of all, they slowed the site down.

However, in my mad theme-a-thon of yesterday and in my subsequent tweaking of each theme to standardize them a little bit and so on, I noticed this plugin really didn’t handle different theme’s varying separators. When I print out the categories for each post, I do so via a call like this:

<?php the_category('<br />') ?>

What this does is it prints out the list of category links (linked to my own WP’s database of categorized posts). The parameter tells it how to separate each category, in the above case with br’s, so in that example, all the categories will be on their separate lines (this is from the Barthelme theme). There are all kinds of possibilities: Chocolate Bar uses vertical bars as separators, and DR’s default theme uses commas.

The wp-CaTT plugin, however, is set up so that when I drop it in and use it, I need to edit its php file to set a variable to the same value used in the call to the_category.

Obviously when I started using multiple themes, that became a problem. So I went poking about in the plugin’s code, and found this:

    // 1. SET THE Delimiter TO THE CHARACTER YOU'RE USING TO SEPARATE MULTIPLE CATEGORIES APPLIED TO THE SAME POST.
    // FOR EXAMPLE, IF YOUR INDEX.PHP FILE CONTAINS the_category(', ') YOUR Delimiter IS ", ".
$Delimiter=", ";

which I replaced with (after tinkering with several other ideas):

    if (preg_match("/,/", $url))
            $Delimiter = ", ";
    else if (preg_match("/<br ?\/>/", $url))
            $Delimiter = "<br />";
    else if (preg_match("/ \| /", $url))
            $Delimiter = " | ";
    else
            $Delimiter = ", ";

There’s probably a better way to gracefully handle it if none of the matches work. I thought of defaulting to a simple space, but the problem is the $url variable is basically a list of href’s so there’s plenty of spaces, and such a default if it got used would result in a mess on my screen. I suppose that would be one way to alert me to the need to add another check.

I’ve been trying to think of a nice way to allow wp-CaTT to be flexible about what it can recognize and match against. One issue is that the $Delimiter variable needs to be set to whatever the actual delimiter is. I can’t just use a longer regexp that combines all the terms, because the plugin reassembles the original href’s with the added Technorati tags, using the delimiter. In addition, I can’t just use the list of delimiters straight, I have to regexp-ify them. In other words, the delimiter " | " has to be escaped because the vertical bar carries special meaning in regexp’s. Or the br took an optional space (” ?”) because some people put down <br /> and others <br>. Hmmm…I suppose people also put down just <br>, too… ‘k…

   else if (preg_match("/<br ?\/?>/", $url))

that fixes that…

I suppose I could take the tack that the Technorati bubbles themselves become the separators, and leave the delimiter empty. But then a theme like Barthelme points out the need to preserve it anyway, because Barthelme prints each category out on its own line and the cleanness of that presentation is spoiled if the categories start wrapping instead.

del.icio.us:wp-CaTT modifications  digg:wp-CaTT modifications

Comments

theme-a-thon!

Having MUCH too much fun with theme rotation… :-D

Actually though, I think every theme developer should play around with something like this. Because I’m starting to develop some very strong preferences for basic setups, such as:

  1. always package up your theme in a directory so when I unzip it, it keeps everything tidy in it’s own directory, ‘k?
  2. don’t make your sidebars (or other .php files) so weird I can’t drop in copies of my already tweaked sidebars in! (I found one theme that closed off a div before starting the sidebar div — which meant it didn’t play well with anyone else!)
  3. make sure they use the right hooks and such…I found some that didn’t incorporate some of my auto-plugins (ones that didn’t need stuff added to files in the theme directories) — those went buh-bye though I liked them…

Note that the only mods I did to these themes was to ensure that they all had a theme handler in the side bar so that no one gets stuck in a theme with no exit. But in the longer run, I want to set them all up with soft links to the same sidebar.php file. I’ll also need to tweak some a bit for the category/technorati tags to come out right and such. But this is fun…

Okay, enough lunch time play…back to work!

del.icio.us:theme-a-thon!  digg:theme-a-thon!

Comments

Bad Behavior has blocked 953 access attempts in the last 7 days.