How do I convert a theme hook suggestion into a function in template.php?

Here is an example I pulled using TEMPLATE_preprocess_field() with dpm().

enter image description here

What would I name my function in template.php to utilize field__field_video_virtual_tour__basic_drealty_listing, and where can I find the default theme function for a text field to use?


The default theme function for all fields is (wait for it), theme_field(). You can copy this function into your own theme, and rename it to MYTHEME_field(), either to alter or to refer to as reference.

You would then name your specific version MYTHEME_field__field_video_virtual_tour__basic_drealty_listing(). Note the two underscores separating the parts.

For reference, the standard suggestions are

  • MYTHEME_field()

Also remember, these are really just to wrap your elements with some HTML. If you want to change the way the element itself gets rendered out, you should really make a field formatter.

  • You're absolutely right. A custom Field Formatter is what I was ultimately needing. This did answer my theme override question as well though, thank you @MPD.
    – Citricguy
    Apr 24 '14 at 2:31

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.