By michaeldhart on
I'm upgrading a site of mine to 6.x, and had used a code snippet which worked well by creating a function in template.php called by a variable in node.tpl.php. This injected the terms into the class of each node, allowing me to theme them via css.
The snippet is broken in 6.x so I did a bit of research...but I'm not really a programmer so I could use some help. Here's what I found:
- _phptemplate_variables() is depreciated, so it will use theme preprocessors which I'm beginning to understand, just don't know enough php to recode the old snippet.
- Also, taxonomy_node_get_terms has changed and again, I can't figure out how to rewrite.
I'd appreciate some help on this, and would love to update the snippets page
Comments
Taxonomy theme module isn't
Taxonomy theme module isn't available for drupal 6 yet :(
But in the meantime maybe this thread and this thread can help you a bit
Looking for something a bit different...
Thanks, francort, I actually tried the dev version of Taxonomy Theme for 6, but it wants to apply an entirely different theme to a particular node or page. Whereas, all I want to do is allow for taxonomy terms to become css classes so I can apply a style based on which term the node has. If it helps, here is the code I'm trying to convert to 6 (found it here):
...which goes into the template.php and:
class="<?php print $node_terms; ?>"...which goes into both the body tag of page.tpl.php and node.tpl.php
Does that make sense?
So, hackin' around a bit, I
So, hackin' around a bit, I got working what I wanted to. thought I'd post it in case anyone is interested. I modified the code above, but only wanted to modify the class of a node, not a page, so I got rid of the extra code pertaining to styling a page and just kept the node stuff:
Put this in your template.php file and then this:
class="<?php print $node_terms; ?>"in the node.tpl.php file.
Subscribing, greetings,
Subscribing, greetings, Martijn
To get it working on the page
To get it working on the page (in body)
Simply preprocess_page
Zen Subthemes
If you're using a Zen subtheme, you'll have to uncomment the override function that applies to pages or nodes (whichever you're trying to use this snippet for). The instructions in the file explain which function overrides what and which line to delete to uncomment it.
Then rebuild the site registry in order for the changes to take effect.
This is just something I ran into, so I'm sharing it here.
Could you be more
Could you be more specific?
I've tried adding the above into override function of /zen/subtheme/template.php without success.
Here is where I added it, around line 130.
but when I load up my site I simply get a blank page. I'm guessing it's conflicting with the other zen_preprocess_node function in the main zen theme?