I'm in a custom tpl.php file. I'm also highly confused!

This line renders nothing...


This line drops the subtitle as expected but in the Devel_Themer formatting.


I'm trying to custom-theme a content type in a custom node.tpl.php file. Everything should work as expected... but, of course... it's not. Any ideas?

  • I'm not sure what you're trying to achieve, but if you are trying to print the value of field_subtitle, you shoud use field_view_field() function. For example: <?php print render(field_view_field('node', $node, 'field_subtitle')); ?> – Jack-PL May 14 '13 at 21:27

It looks like you could use:

print $content['field_subtitle']['0']['#markup'];

or else just

print render($content['field_subtitle']);
  • Also, you could just dump everything on the screen by using something like print '<pre>' . check_plain(print_r($content, 1)) . '</pre>'; if you're having trouble figuring out what is or isn't available to you... – jerdiggity May 14 '13 at 23:45
  • print render($content['field_subtitle']); is the right way to do it - it checks for sub-elements hidden before in template with hide() – Mołot May 15 '13 at 6:29
  • I'll tell you what it is... – randomblink May 15 '13 at 17:49
  • I haven't touched PHP in a few years (I've been working on my deltoids, lol) and I forgot to print before render... so I was just rendering... ugh. – randomblink May 15 '13 at 17:56
  • @randomblink Don't forget to accept the answer if it helped to solve the problem, you can do that by clicking the tick mark next to the answer :) – Clive May 15 '13 at 18:15

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.