I fear that my question could be covered in detail already somewhere, but I did not find something useful. So appologies if this is the case.

I added a field of type "Text" to content type "Article". Now, I want to access the string of this field.

I want to access this in file template.php of the theme I use. To be precise, I want it to access in function "tb_corpal_preprocess_page". (File from themebrain theme "tb_corpal".)

I can see that in another function the "field_image" is accessed like this:


If I now want to extract my field_banner, which is a field of type "Text", how do I do that? I guess it should also be stored in $vars, right? If yes, how do I access the string?

1 Answer 1


start by downloading the devel module.

A suite of modules containing fun for module developers and themers ...


Helper functions for Drupal developers and inquisitive admins. This module can print a summary of all database queries for each page request at the bottom of each page. The summary includes how many times each query was executed on a page (shouldn't run same query multiple times), and how long each query took (short is good - use cache for complex queries). Also a dprint_r($array) function is provided, which pretty prints arrays. Useful during development. Similarly, a ddebug_backtrace() is offerred. much more.

This includes a function dpm() which allows you to navigate through complex variables including $vars. dpm($vars) will create a user interface for navigating through it - then you can find the specific location for the field you want.

I included this as an answer instead of the presumed actual location of the field within $vars since this allows you future access to any variables you need. You can use this for example to go through a $form, $content, etc.

  • Solved my problem. It was so deeply nested, would have never found out without dpm(). thanks!
    – Michael
    Oct 28, 2014 at 0:39
  • I know the feeling, it's a very powerful little tool given how data is managed in Drupal
    – Geoff
    Oct 28, 2014 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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