Drupal

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:

  1. Using theme_menu_tree e.g. Navigation menu, any menu shown via a block.
Posted in:

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:

Posted in:

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.

Posted in:

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).

Posted in:

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.

Posted in:

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);
?>
Posted in:

Using WinCVS

  1. Run WinCVS
  2. Click the Change location icon and browse to a place where you want to work on something from the repository. This location can be anywhere outside the c:/cvs folder. Basically, you will be checking out something from the repository, and saving it here to do modifications on it. Once you have done your modifications, you can commit any changes back to the repository.
  3. Once you have your folder selected, right-click on it the left Modules window, and select Checkout module.
Posted in:

Importing into the repository

  1. For the files you want to add to your repository, make sure that they are available in their own folder somewhere else on your system. e.g. if you want to have drupal in your repository, extract all the files from the tarball into a folder not in your c:\cvs folder.
  2. Open up the Windows command prompt and change to the folder that has all the files in it.
  3. Type the following:

    c:\temp\drupal> cvs import drupal INITIAL start

    Posted in:

Installation and setup of CVSNT & WinCVS

  1. Install CVSNT 2.5.03 (http://www.cvsnt.org), WinCVS (http://www.wincvs.org) & Python (http://www.python.org) or ActiveTCL (http://www.activestate.com), if you want to run a shell in WinCVS.
  2. Create a folder in your root directory to hold the CVS Repository e.g. c:\cvs.
  3. Go to Control Panel and click on CVSNT Server icon.
    If the CVSNT Service is running, stop it.
  4. Go to Repository configuration, click Add.
  5. For Location, select the folder you created above in step 2 (name gets filled in automatically).
Posted in:

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.

Posted in:
magnanimous-junior