How do I add  tags to the output of a view list? The output of a view I am using contains the following code.

&lt;li class="views-row views-row-1 views-row-odd views-row-first"&gt;  
  &lt;div class="views-field-field-cimg-fid"&gt;
    &lt;span class="field-content"&gt;....&lt;/span&gt;
  &lt;/div&gt;

  &lt;div class="views-field-field-yma-value"&gt;
    &lt;span class="field-content"&gt;...&lt;/span&gt;
  &lt;/div&gt;

  &lt;div class="views-field-field-price-value"&gt;
    &lt;span class="field-content"&gt;....&lt;/span&gt;
  &lt;/div&gt;

  &lt;div class="views-field-changed"&gt;
    &lt;span class="field-content"&gt;....&lt;/div&gt;&lt;/span&gt;
  &lt;/div&gt;
&lt;/li&gt;


I want to add &lt;div id="test"&gt;....&lt;/div&gt; around the following snippet.to group two fields

   &lt;div id="test"&gt;
    &lt;div class="views-field-field-yma-value"&gt;
      &lt;span class="field-content"&gt;...&lt;/span&gt;
    &lt;/div&gt;

    &lt;div class="views-field-field-price-value"&gt;
      &lt;span class="field-content"&gt;....&lt;/span&gt;
    &lt;/div&gt;
      &lt;/div&gt;


the loop

 &lt;?php foreach ($fields as $id =&gt; $field): ?&gt;
  &lt;?php if (!empty($field-&gt;separator)): ?&gt;
    &lt;?php print $field-&gt;separator; ?&gt;
  &lt;?php endif; ?&gt;

  &lt;&lt;?php print $field-&gt;inline_html;?&gt; class="views-field-&lt;?php print $field-&gt;class; ?&gt;"&gt;
    &lt;?php if ($field-&gt;label): ?&gt;
      &lt;label class="views-label-&lt;?php print $field-&gt;class; ?&gt;"&gt;
        &lt;?php print $field-&gt;label; ?&gt;:
      &lt;/label&gt;
    &lt;?php endif; ?&gt;
      &lt;?php
      // $field-&gt;element_type is either SPAN or DIV depending upon whether or not
      // the field is a 'block' element type or 'inline' element type.
      ?&gt;
      &lt;&lt;?php print $field-&gt;element_type; ?&gt; class="field-content"&gt;&lt;?php print $field-&gt;content; ?&gt;&lt;/&lt;?php print $field-&gt;element_type; ?&gt;&gt;
  &lt;/&lt;?php print $field-&gt;inline_html;?&gt;&gt;
&lt;?php endforeach; ?&gt;


how to add the div tags to the loop?
In the View edit screen, click Advanced. At the very bottom of that, you'll find a bit called: Theme: Information. Click the Information link and a new window will pop up, showing you theme overrides for the view. Each category changes different parts of the view.

All of the file names listed on each type will show the available filenames which could be used to override this view, in order of least specific to most specific. So if you pick the first one, it will probably override all of your views, while if you pick the last one, it will only override that view in a certain display.

Once you've picked what you're going to override, click the link and copy all of the code shown there to the clipboard. Then go to your theme directory and make a file with the filename you picked from before and paste in the code you copied. Now just add the &lt;div&gt; tags you want wherever you like.

You'll need to click the "Rescan template files" button for Drupal to pick up your new theme override file. Views shows you which one it will use for the view by putting the one it will use in bold.

Edit: When writing this, I was going through the steps for Drupal 7, but I believe the steps are very similar for Drupal 6.

Next Edit: From the code you have pasted, it looks like the most appropriate place to put the new div tags would be (see the asterisks):

**&lt;div id="my-custom-div"&gt;**
&lt;?php foreach ($fields as $id =&gt; $field): ?&gt;
  &lt;?php if (!empty($field-&gt;separator)): ?&gt;
    &lt;?php print $field-&gt;separator; ?&gt;
  &lt;?php endif; ?&gt;

  &lt;&lt;?php print $field-&gt;inline_html;?&gt; class="views-field-&lt;?php print $field-&gt;class; ?&gt;"&gt;
  &lt;?php if ($field-&gt;label): ?&gt;
    &lt;label class="views-label-&lt;?php print $field-&gt;class; ?&gt;"&gt;
      &lt;?php print $field-&gt;label; ?&gt;:
    &lt;/label&gt;
  &lt;?php endif; ?&gt;
  &lt;?php
    // $field-&gt;element_type is either SPAN or DIV depending upon whether or not
    // the field is a 'block' element type or 'inline' element type.
  ?&gt;

    &lt;&lt;?php print $field-&gt;element_type; ?&gt; class="field-content"&gt;&lt;?php print $field-&gt;content; ?&gt;&lt;/&lt;?php print $field-&gt;element_type; ?&gt;&gt;
    &lt;/&lt;?php print $field-&gt;inline_html;?&gt;&gt;
&lt;?php endforeach; ?&gt;
**&lt;/div&gt;**


I normally experiment a bit with this, so it's a bit difficult to tell you the exact spot offhand, but hopefully the above will be close...