I'm trying to wrap multiple field items in an HTML container.

So let's say I have "Blog" content type. I have field1, field2, field3, field4 and field5 for this content type.

I want to output field2, field3 and field4 wrapped together in a DIV.

I've been Googling and tinkering for the past 3 hours and I haven't gotten anywhere.

Any help out there?

Drupal 7, Zen subtheme.

I read this and didn't have any luck here either: Wrapping multiple cck fields into a single div tag for theming?


2 Answers 2


Multiple ways to achieve this.

  1. By creating a node tpl file for that particular content type.
  2. By creating view.
  3. But i think the best and easiest way is creating group in manage display. Check field group module.

Procedure to create group.

  1. Go to structure->content types->content(ex-blog)->manage displays.
  2. Add a new group of div type.
  3. Drag the required field like field2 , field3 etc under it.

Print in tpl file.

It will be easy to find out if you will update the code snippet of node--case-study.tpl.php file.

I think you need to first check by printing

echo '<pre>';

and use this for

<div class="y">
  <?php print($content['field1']); ?>

<div class="x">
  • Thanks but the field group module doesn't actually output any extra HTML to the actual page. Creating a view won't allow me to wrap multiple fields in a DIV to my knowledge and I'm struggling with the node.tpl.php method.
    – Papa Bear
    Commented Oct 10, 2014 at 21:08
  • ok can you let me know what problem you are facing with node.tpl.php.
    Commented Oct 11, 2014 at 6:21
  • 1
    Noting that unlike @PapaBear, I could (with the field group module) output extra HTML to the actual page by making and configuring the field group in Manage Display (though I only tried this in an 8 site). Noting this in case the comment raises doubts for other users as it did for me. Commented Jun 20, 2018 at 15:52

Create a empty file with name [node-ContentType.tpl.php] for your content_type node template file and place it at sites/all/themes/your_theme/templates. Flush all caches.

In this file you have the access $node variable which contains the all fields in that node. Now wite your custom html to breakdown your fields into differnt divs.

<div class="first-pane">
  <?php print $node->field1[0]['value']; ?>
<div class="second-pane">
 <?php print $node->field2[0]['view']; ?>
 <?php print $node->field3[0]['view']; ?>
 <?php print $node->field4[0]['view']; ?>
<div class="third-pane">
  <?php print $node->field5[0]['value']; ?>

For further parameters details, try this.

  • I tried this and I receive this error: Notice: Undefined offset: 0 in include() (line 11 of C:\xampp\htdocs\drupal\sites\all\themes\cp\templates\node--case-study.tpl.php). If it helps to know I also have a page--case-study.tpl.php, not sure if these might be conflicting.
    – Papa Bear
    Commented Oct 10, 2014 at 21:05

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