Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Refresco and Drupal 6 Theming

Parent Feed: 

"I need to fix just this one last thing."

So, what do you do when you have 5 large-ish projects about to start in the next couple of days, you have paperwork to do, you have conference calls to attend, and cats to feed? You make a new Drupal 6 theme for Drupal.org, what else?

Apparently that is what I do rather. This is how Refresco, my new Drupal 6 theme, came about. I started poking at it about 7am, thinking I would just change a thing or two about a theme I was toying with contributing and get to work on another project, and before I knew it it was 11pm and I had submitted it. Not quite sure if anything else happened during the day...

A Very Cool Theme

Ok, I am biased, but Refresco is a killer theme. I designed it to make good use of space. For example I have a section up top to display messages that the system will on occasion give you. Well that space is currently occupied by the search bar, but are you searching when you are reading a Drupal message? Nope, so they share the space.

How about your secondary menu area, do you need to see that all the time? Not if you don't have secondary links for that page, so it just hides, same with breadcrumbs, side columns, and even one of the horizontal regions.

In all this template has 6 actual regions, and a couple of other areas that work as needed.

screenshot of refresco

One of the things I like to find when I use a template is that it is easy to modify, so that is how I make my templates, easy to change. I put all of the background color information at the top of the style sheet so that it can be gotten to easily and try to use no graphics if I can help it. I didn't use any graphics for layout or design in either of these themes, so when you change the CSS the whole look changes and you don't have to go sifting through the Photoshop jungle to fix a rounded corner or change a background graphic.

Drupal 6(mostly) Theming Notes

Some things that I need to brush up on for Drupal 6 theming (or theming in general perhaps), which I may implement more fully in Refresco and other D6 themes later:

  • theme-settings.php - Using this file and a little knowledge that I couldn't be bothered to gather in my mad rush to create the theme, I could have set the search box to be switched on, as well as the mission statement, slogan, logo, or any other normal theme setting as far as I can tell
  • Passing variables to the theme - seems like if I put a conditional statement in my preprocess function in template.php that my $vars['variable_I_want_to_set'] would just plain not get set. Not sure why. MUST figure this one out
  • The secondary links menu block is only for a menu you create or use under Menus that is named secondary links, it will NOT display your secondary links from your primary links menu, or any other menu that is filling the "secondary links" role under Menus -> Settings - maybe this is just as appropriate for D5?
  • theme('links', $primary_links) works, theme('links', $primary_links, '') does not :)

I Had a Title Here Just a Minute Ago?!?

One other gotcha, and it's one that I think also happens in Drupal 5, is that the front page didn't display my $title, because it was displaying a teaser, and not a full page. To address this I had to use the following code prepended to my node.tpl.php file:

  <?php if ($page == 0): ?>
    <h2 class="title">
      <a href="http://brauerranch.com/<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>
  <?php endif; ?>

This code ensures that if I was viewing full pages, it wouldn't print the title twice, but it did produce my title nicely on the front page, and gives a nice title link to the full content.

Other Lessons Learned

It's actually really cool that after contributing my first theme, Ranch, just a couple of days ago, that I also wrote up a handbook page called "CVS quick-start guide for theme maintainers" to help me remember how to do it, and to help others along the theme contribution path. Anyhow, I say it's cool because last night I was probably the first user of that document.

It needs a little improvement, but overall, it took me less than 1/2 hour to contribute this theme, as opposed to the several hours it took the first time. Practice makes perfect I guess.

I will be making some improvements to that handbook page, especially mentioning Drupal 6 tagging/branching specifics, as well as the formats for the $Id$ and that they should be included in your source files.

Well, I think that's enough for now. I have to get going to work, right after I tweak just this one thing...

Author: 
RSS Tags: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web