I am using devel and <?php dpm($items); ?> in my field template file so the node looks like the following.


I can print the #theme element (which is a string) with the following code.

<?php print $items[0]['#theme']; ?> 

What is the syntax to print elements in an array such as URLs, labels, titles?


You'll have to follow the trail in the DPM structure. The url field is under the #element element. The #element element is under the 0 element. This means you can access the value of url with:


You can reach the title element in a similar way.

The value of #theme is directly under the 0 element, that is why you could access it with:

  • @ Jesse thanks but I don't want to use dpm I want to use print ie corresponding to my #theme example. By url I meant the url element of the #element array ie the one highlighted in red in the screenshot ie what is the syntax to print this string? – Juc1 May 16 '14 at 14:50
  • Your question is not clear. The elements URL and label are in your $items array, what do you mean with printing them in an array? – Jesse May 16 '14 at 14:57
  • Ok let me try again - I can print the #theme string with '<?php print $items[0]['#theme']; ?>' Now I want to do the same thing for the url string (the one highlighted in red) ie to print just the url string on its own. I think the answer I am looking for will be something like '<?php print $items[0]['#url']; ?>' – Juc1 May 16 '14 at 15:12
  • Ah, it should be <?php print $items[0]['#element']['url']; ?> I'll update my answer to explain – Jesse May 16 '14 at 15:22

where did you output the dpm? double click on any of the attributes then it shows you the trail array which displays that content. like this

enter image description here

then use this array key at the beginning of the variable passed in your hook preprocess function. for example:

function hook_preprocess_node(&$variables){
    $variables['value'] = $variables['revision_timestamp']

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.