When using Views, I always use fields instead of content. But I noticed that Views does not show the machine name of a field and it only assumes that you already know it. Is there some other way to find out the machine name?

Knowing the machine name lets me access the field directly like so

print $fields['machine_name_here']->content;
  • Where do you need the machine name? In a template?
    – Oswald
    Aug 5, 2011 at 8:55
  • Yes. I need it so I can lay it out like in the sample code above.
    – enchance
    Aug 5, 2011 at 9:03

2 Answers 2


Go to the settings page of a view, and click on "Theme information"; then you look at the IDs of each field. For example, if "Theme information" shown this information, then "last_comment_name" would be your machine name.

Field Node: Last comment author (ID: last_comment_name):

  • So it is! Sneaky little bastard hiding in the theme info.
    – enchance
    Aug 5, 2011 at 9:23
  • 4
    lol i helped someone yeesssss!!!! 4 years of working with drupal and not knowing a bit of code has finally paid off for me enchance.
    – Reg Gordon
    Aug 5, 2011 at 9:36
  • Haha best comment evaaar!
    – enchance
    Aug 5, 2011 at 11:17

If you use the devel module (highly recommended) you could also insert a function to show you all the available fields for the view:

<?php dpm($fields); ?>

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.