Blogs
Adding an "active" CSS class to the <li> element in menus
I seem to keep finding different ways to add an "active" CSS class to <li> elements in menus. I must have been a bit dense, but it took me a little while to figure that menus are displayed using different methods, hence they need different ways to add in the extra class. Here are the methods:
- Using theme_menu_tree e.g. Navigation menu, any menu shown via a block.
Adding an "active" class to menu links
This method works on all menus that are displayed as blocks i.e. not primary or secondary links. These sorts of menus are created using the theme_menu_tree() function. The process here is a bit more complicated than for primary links, but all you have to do is paste in the code below (I have done all the heavy lifting for you).
Put this in template.php somewhere:
Adding an "active" class to primary links - Option 1
Because primary links use theme_links to generate their output, we could override that theme and add in our own code to get an "active" class on the <li> element. Drupal 6 made some improvements to 5's theme_links function, so I used that version and added in some code to check for the front page too.
SEO, Meta Tags module and <title> tags
If you're one of those SEO obsessed people and if you're also a Drupal user, then you'll probably know about the Meta Tags module (also called Nodewords). You might even know about the Page Title module too. And, just maybe, you've also tried to find a way to change the <title> text, not only on nodes (which Page Title does just fine), but also on taxonomy/term pages (which neither module does at all).
Tertiary menus in Drupal
In keeping with the theme of the previous post, here is another fantastic tip for pulling out more levels of your primary links menu.
By default, Drupal gives you primary and secondary links. These can come from the same menu tree; primary links will be the first level, and secondary links will be the second level. But what happens when you want the third level? Drupal does not give you this variable by default.
Adding an "active" class to primary links - Option 2
There are quite a few posts about setting the active trail properly with primary & secondary links. In Drupal 5.x, its actually handled pretty well if you use the following code to print your primary & secondary links in page.tpl.php
<?php
print theme('links', $primary_links);
print theme('links', $secondary_links);
?>Back in the Great White North & Boston Drupalcon 2008
After an almost 3 month vacation in the South, I have returned to a cold and snowy Montreal. I was hoping that I had skipped out on the winter weather, but 20cm of snow greeted me on my return and gave me the opportunity to work on shoveling technique. We're rapidly running out of space to put the snow, so spring better get here quickly :)
phpMyAdmin search and replace
Here is a great tip that can save you hours of work. Sometimes you have messed up characters in your database - wrong character encodings - or you want to strip out some text in a certain table's field. In phpMyAdmin, open up the SQL dialog and use the following code (change tablename and tablefield to your name and field values):
UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring");
You can also tack on a WHERE statement, if you like.
Vacationing in the southern hemisphere
Hi all,
Just thought I'd share a photo taken on my vacation in Cape Town, South Africa - where I currently still am. Just my way of sending a little bit of warmth and sunshine up to the folks in the northern hemisphere...

Using a local CVS server to run a Drupal site
Seeing as I have a lot of work these days, and clients are always asking me to tweak stuff, I thought it might be a good idea to have some sort of version control on the stylesheets, template files & modules, that I work on. That way, if something I do breaks something else, I'll be able to rollback more easily to a previous working version.
So I set about trying to figure out how to do this on a Windows XP machine using CVSNT and WinCVS. Information is pretty sparse on the ground, especially for CVSNT v2.5.03 - most info is for older versions.