hi,
i've been working on our website http://flexmens.org, we've just recently switched to drupal 6 and are using a slightly adapted Garland theme.
I've had a problem with one thing, which is styling the category name on a few pages. The category page is displayed when you select one of the tabs/secondary links such as 'migratie' and 'copyrights'.

I want this category to be in a lighter color, but if I style the h2-tag (within the left-corner div) directly and indiscriminately without selecting a particular class name, the result is that the post title in another page, where only one story is displayed, gets the same color. This is because it also does not have a class name, and is the same element inside the same div.

What I would like to ask is how I can add a classname to the h2 tag so that only the category name is styled, rather than all h2 elements.

Most elements have some classname associated with them or can be targeted more precisely, but I have the feeling in this case I need to go into a php template file and add the classname there.

My php knowledge is limited, and when I've changed something there, I got some error messages cropping up, so i think I'm doing something wrong, perhaps with single quotes or double quotes, but I'm not sure that is the problem.

If there's anyone who can give me a pointer on how to proceed, I'd very much appreciate it.

Comments

francort’s picture

I hope a span tag with a class should be enought.
1) Add this piece of code at the end(exactly before }) of phptemplate_preprocess_page function which is inside your template.php file:

if(arg(0)=="taxonomy" && arg(1)=="term" && is_numeric(arg(2))){
    $vars['is_taxonomy_page'] = true;
  }
  else{
  	$vars['is_taxonomy_page'] = false;
  }

Now we have a new variable to know if it is a taxonomy page or not.
We can use that variable on page.tpl.php

Find this piece of code:
if ($title && !$is_taxonomy_page): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif;

and replace it with
if ($title && !$is_taxonomy_page): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>';
elseif ($title && $is_taxonomy_page): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'><span class="taxonomy-title">'. $title .'</span></h2>'; endif;

Now you should have a span tag with a class called "taxonomy-title".

Good luck!

PS: I almost forget this: you'll need to clear your theme's cache( unenable and reenable your theme )

thijsx’s picture

ok cool, thanks very much, I'm going to try this asap. I thought it would be simpler, I thought there would be one particular template for the taxonomy page but actually it makes sense that there isn't.

thanks for taking the time.

oh yeah, another question, not all tabs remain in 'active mode' on the taxonomy pages (in the current design, only visible in firefox with moz-opacity), because they do not all get the class 'active'. Is there a simple solution to that? I've made new tabs, and they also don't get that class, whereas some older tabs that were in there already before, do.
I don't see any structural difference between the tabs that work and the ones that don't.

francort’s picture

When you're adding items for a menu, you must avoid to use "http://www.flexmens.org/drupal/?q=taxonomy/term/1" but use just "taxonomy/term/1".

(Off topic, just an advice)You can rename your urls with Path module(core optioinal module). With that you can have a "/?q=migratie" path. Even better when you have clean url's enabled. Pathauto module can help you as well.

Good luck!

thijsx’s picture

great, thanks

I just applied the code from your first reply, works like a charm!