Search code examples
drupalcckpreprocessortheming

preprocess function for cck node types


(Note: I originally posted this on drupal.org before remembering that I never get a response over there. So, sorry for the cross-posting)

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


Solution

  • I think that you're looking for this post. There's no magic per-node preprocess, only per theme/template engine, but you do have access to the node type in the $vars parameter so you can switch on it there.

    Hope that helps!