Hello, is there a way (built-in or otherwise) to add preprocessing functions for particular cck node types? I am looking to do some preprocessing of a field within my cck node type. Currently I can either use theme_preprocess_node and then do a switch on the $node->type or use a theming function for a particular field name (and still do a switch to make sure the current field usage is within the node type i'm looking for). What I am suggesting is to have a function like this...
theme_preprocess_mynodetype(&$vars) {
// Now I can preprocess a field without testing whether the field is within the target content type
}
...but I can't figure out if I can suggest preprocess functions the same way I can suggest template files
Thanks! Rob
Comments
I usually add something like
I usually add something like this to my template.php file for my theme.
Which then lets me have preprocess functions like:
Nice one, I'll give that a
Nice one, I'll give that a shot, thanks! rob
I'm trying to use this
I'm trying to use this function to do the same thing as you have listed above. I included it in my template.php file and have even printed the $function variable to make sure that I have the right function names.
I load the page and am able to see that the theme_preprocess_node that I defined was called, and I see the function name it's supposed to call listed. For some reason though the variables that I added to the vars array are not appearing on the page.
... am I missing something?
Make sure you're passing your
Make sure you're passing your variable by reference.
So, make sure your function signature is as follows.
function myfunction_preprocess(&$vars) {The "&" is essential here.
If that's not it could you paste your code so we can take a look and see if there is anything obvious missing.
What's more important is that
What's more important is that I spell process with two 's' ... not one. Works like a charm.
Thanks!
thank you!
awesome.
D7 Version
Here is the D7 version. Extra underscore to follow conventions.
Another Approach
Instead of creating a new function for each content type. Why not use if statements within the variables preprocess function to control the action for each content type. It's easy to read, and you can just add new sections when you add new content types.
Wylbur
http://groups.drupal.org/twin-cities