In a content node, I wanted to wrap a div around some results. For example: I have this inputs:

Image Title Body Address Email Name

And I wanted to have divs like this: DIV Image Title /DIV DIV body Adress Email /DIV DIV Name /DIV

Is this in any way possible?

  • Have you thought about creating a custom node.tpl.php for the content type (drupal.org/node/17565) then pulling the field values wrapped with anything you want? Jul 22, 2014 at 22:24
  • I thought about. But how do I divide the results in different divs on php? Jul 22, 2014 at 22:50

1 Answer 1


So, if you create a new .tpl.php for your content type, you can simply print the divs as html, and echo the vars as php.


<div class="MyClass">
<?php print $title; ?>
<div class="MyOtherClass">
<?php echo render($content['some_field']); ?>

See https://stackoverflow.com/questions/8074485/drupal-7-how-to-render-custom-field for a starting point on pulling specific custom fields, for separation, if needed.

be sure to have a copy of your original node.tpl.php in your theme folder as well, or your node--my-content-type.tpl.php wont work! Again, see https://www.drupal.org/node/17565.

  • I could kiss you, Daniel! It worked! Jul 23, 2014 at 4:06

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.