Views - Add a wrapper DIV around a Group In Drupal 7, I have created a View that lists several fields. The fields are grouped by another field (the term ID of the field). The mark up looks like this:

&lt;h3&gt;[Term 1]&lt;/h3&gt;
&lt;div class="views-row views-row-1 views-row-odd views-row-first"&gt; [Field Content] &lt;/div&gt;
&lt;div class="views-row views-row-2 views-row-even"&gt; [Field Content] &lt;/div&gt;
&lt;div class="views-row views-row-3 views-row-odd views-row-last"&gt; [Field Content] &lt;/div&gt;

&lt;h3&gt;[Term 2]&lt;/h3&gt;
&lt;div class="views-row views-row-1 views-row-odd views-row-first"&gt; [Field Content] &lt;/div&gt;
&lt;div class="views-row views-row-2 views-row-even"&gt; [Field Content] &lt;/div&gt;
&lt;div class="views-row views-row-3 views-row-odd views-row-last"&gt; [Field Content] &lt;/div&gt;

&lt;h3&gt;[Term 3]&lt;/h3&gt;
&lt;div class="views-row views-row-1 views-row-odd views-row-first"&gt; [Field Content] &lt;/div&gt;
&lt;div class="views-row views-row-2 views-row-even"&gt; [Field Content] &lt;/div&gt;
&lt;div class="views-row views-row-3 views-row-odd views-row-last"&gt; [Field Content] &lt;/div&gt;


However, I need the mark up to look like this:

&lt;div id="term_1"&gt;
     &lt;h3&gt;[Term 1]&lt;/h3&gt;
     &lt;div class="views-row views-row-1 views-row-odd views-row-first"&gt; [Field Content] &lt;/div&gt;
     &lt;div class="views-row views-row-2 views-row-even"&gt; [Field Content] &lt;/div&gt;
     &lt;div class="views-row views-row-3 views-row-odd views-row-last"&gt; [Field Content] &lt;/div&gt;
&lt;/div&gt;

&lt;div id="term_2"&gt;
     &lt;h3&gt;[Term 2]&lt;/h3&gt;
     &lt;div class="views-row views-row-1 views-row-odd views-row-first"&gt; [Field Content] &lt;/div&gt;
     &lt;div class="views-row views-row-2 views-row-even"&gt; [Field Content] &lt;/div&gt;
     &lt;div class="views-row views-row-3 views-row-odd views-row-last"&gt; [Field Content] &lt;/div&gt;
&lt;/div&gt;

&lt;div id="term_3"&gt;
     &lt;h3&gt;[Term 3]&lt;/h3&gt;
     &lt;div class="views-row views-row-1 views-row-odd views-row-first"&gt; [Field Content] &lt;/div&gt;
     &lt;div class="views-row views-row-2 views-row-even"&gt; [Field Content] &lt;/div&gt;
     &lt;div class="views-row views-row-3 views-row-odd views-row-last"&gt; [Field Content] &lt;/div&gt;
&lt;/div&gt;


I know that you can use views-view-unformatted.tpl.php (Style Output) to over ride the view and then insert a DIV to wrap the group. 

However, I need my wrapper DIV to be like this  &lt;div id="term_ID_{number of ID}"&gt;. The number ID will correspond to the term that has been used to group the fields. By default, if you use views-view-unformatted.tpl.php, you cannot insert tokens for term IDs into it. 

Any help would be appreciated.
I needed to do this same thing recently. You can create a template file:


Find the template under /modules/views/themes/views-view-unformatted.tpl.php. 
Copy it into your /sites/all/themes/&lt;your-theme&gt; folder and rename to views-view-unformatted--&lt;nodetype&gt;.tpl.php. 
Edit the file adding a div around the entire template. The &lt;h3&gt; tag is the group name.


Here is what the modified template file might look like.

&lt;div class="your-class"&gt;
&lt;?php if (!empty($title)): ?&gt;
    &lt;h3&gt;&lt;?php print $title; ?&gt;&lt;/h3&gt;&lt;!--this is the group name--&gt;
&lt;?php endif; ?&gt;
&lt;?php foreach ($rows as $id =&gt; $row): ?&gt;
  &lt;div class="&lt;?php print $classes_array[$id]; ?&gt;"&gt;
    &lt;?php print $row; ?&gt;
&lt;/div&gt;
&lt;?php endforeach; ?&gt;
&lt;/div&gt;&lt;!--end your div--&gt;