Oh Drupal themes. How I hate you.

Oct 28, 2009 | Uncategorized | 0 comments

Over the past few days, I’ve learned far more than I ever wanted to learn about Drupal themes. A website that I’m working on needs to conform to W3C web authoring and accessibility guidelines. This has meant that I’ve had to jump through all sorts of hoops to make Drupal, what I thought was a very clean content management system, display content in a very accessible way.

I’ll not claim to be a Drupal expert. There are a lot of really smart Drupal people out there who can tell you how everything fits together. But, the problem is, there seems to be very little documentation for those of us who have joined the party late. Up to version 6, I really had no idea how all the parts of Drupal fit together. The last time I used Drupal was 4.7 about three years ago. Back then, I didn’t really need to do anything that involved diving into the code of the application and from what I gather, it’s a lot more complicated now than it was then!

Now, when I want to do something, I can never be completely sure what is calling the function I want to use or where the theme is even putting it. Object orientated programming is fantastic and using functions to only call something once is really the only way to develop something properly but when you’re coming at an application as an outsider, it can be very difficult to trace through what’s happening from the top down.

Take the read more link for example. That breaks web standard guidelines for accessibility but what the hell generates that link! Where is the function that it’s created in? I’ve no idea! So, as a dirty hack, I have to put a Claus at the top of the template so that if it sees a specific link that contains the read more text, it recreates that link with the read more text as well as the title of the current node. But even with this I have problems. By default, the home page doesn’t set the title variable to anything so I have to have a clause before this that first checks for the existence of the title variable, then checks for text in it. If no text is found, I have to put the title of the home page in it then move onto the next check.

The other problem was the Drupal formatting of this read more link. For some reason, it was in a list containing one item at the top and the bottom of news items. This was visually ugly and from the perspective of a screen reader user, it created unnecessary clutter. There is a Drupal module for fixing this actually but when I used it, my little hack for inserting the title into the read more link no longer worked. I did some tweaking but still, although I can change the text, the title variable does not seem to be exposed to the new module. So, I’ve more work to do on this. I may need to request the assistance of the creator of this module if he’s willing.

My latest problem is with colours. I’m using a great theme that’s customized extensively to meet the needs of the users of this site. But, although everything is almost finished, to make the site comply to these W3C guidelines, I have to add the option of making the site high contrast. This means that the text would really stand out from the background to make it easier to read. The problem is, there is no clean way of doing this in Drupal. The colour module just doesn’t cut it.

After some looking around, I found that another user had successfully used a different style sheet for the same theme to create the high contrast look however these tips were for an earlier version of Drupal and things have changed since then so I couldn’t figure out how to apply his suggestion to the version of Drupal that I’m running.

So, my only alternative that would provide this functionality to anonymous users as well as authenticated users was to create an entirely new theme that was modelled on the original one but that had the high contrast colour scheme.

After a few hours of work, this is finally done.

I’ve got the theme working for authenticated users because Drupal provides the change theme functionality within the user profile page however, it’s not easy enough to use yet.

I’m still looking for a better way of changing between themes for both authenticated and anonymous users.

I’m looking for something that will sit in a block on every page that has a toggle link for normal or high contrast depending on what is currently running.

I think I may have found a solution, but again, it requires more work.

I think it’s time I stop working on unpaid projects. Ha! Did I not mention that? All of this is being done for nothing! But, in saying that, I offered.

So, there you have it. The joys of working with Drupal.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.