0

I have a file called template.php and inside the template file I have a preprocessor but I have two problems I don't know if the preprocessor is loading and if the code in the file is right.

The code inside the file is

function template_preprocess_field(&$vars) { kpr($vars); //Uncomment to output the $vars array. }

At this stage all I am trying to do is see if I can get the node to give me some feedback but I get nothing. The nodes I am testing this on does have three fields

  • Version numbers and location of template.php is required to answer your question. – user7667 Jul 20 '12 at 7:04
  • drupal7 and themename->templates->template.php – gistworld Jul 20 '12 at 7:13
2

Your template file should reside in the sites/all/themes/mytheme/ directory. Not in the templates subdirectory. Furthermore, your preprocess function should be named mytheme_preprocess_field(). Be sure to clear your cache.

You might want to perhaps also look at the Devel Themer module. It should provide information on the preprocess function being used and so on. I'm unsure how well it works with Drupal 7. But it's worth your time if it does.

0

Definitely, definitely get the Devel Theme module. It can be a great help in Drupal 7 when digging through the arrays on that page so you won't make any mistakes. It will give a simple list of the field names you can then call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.