Views - Add a wrapper around fields or rows Example:

I have a view with fields:

[field_name]    == Field collection item: Name
[field_title]   == Field collection item: Title
[field_text]    == Field collection item: Text


I can wrap these fields by excluding from display first two of them, and rewriting the output of the third field with tokens, for example:

&lt;div class="span4"&gt;
    &lt;div class="some_style"&gt;
        &lt;blockquote&gt;[field_text]&lt;/blockquote&gt;
        &lt;h5&gt;[field_name] // [field_title]&lt;/h5&gt;
    &lt;/div&gt;
&lt;/div&gt;


It seems a bit tricky, so here is my first question: 

Is there any module or just another way to wrap fields in views?

I know Semantic Views module which solve the problem, but there is no recommended releases for Drupal 7.

Question #2

All my fields are wrapped in their div like in above mentioned example, but this is only the one row, and I have several rows. I need wrap all of them in another div. 

Do I have to create a view template file only for that? which contain for example:

&lt;?php if($rows): ?&gt;
    &lt;div class="rows"&gt;
        &lt;?php print $rows; ?&gt;
    &lt;/div&gt;
&lt;?php endif; ?&gt;


I have a feeling like I miss something when I have to create a special template file only for one wrapper.
I think it's pretty safe to say that most people tackle both of your questions using the Cascading features of CSS.

For example, a typical view's HTML looks somewhat like this:

&lt;div class="view view-NAME view-id-VIEWID view-display-id-VIEW-DISPLAY-id"&gt;
  &lt;div class="view-content"&gt;
    &lt;div class="views-row views-row-1 views-row-odd views-row-first"&gt;
      &lt;div class="views-field views-field-FIELDNAME1"&gt;
        &lt;span class="field-content"&gt;
           &lt;!-- field content here --&gt;
        &lt;/span&gt;
      &lt;/div&gt;
      &lt;div class="views-field views-field-FIELDNAME2"&gt;
        &lt;span class="field-content"&gt;
           &lt;!-- field content here --&gt;
        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="views-row views-row-2 views-row-even"&gt;
     &lt;!-- etc etc etc --&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


So, to your 1st question, Views already creates a div that wraps each row, that's the &lt;div class="views-row ..."&gt; one.  You can style it per view by doing something like this:

.view-NAME .views-row {
  /* styles for the rows div goes here */
}


And to your 2nd question, Views also already creates a &lt;div&gt; that wraps all the rows, that's the &lt;div class="view-content"&gt; one.  To style it for a particular view you can do something like this:

.view-NAME .view-content {
  /* styles for the div wrapping your rows goes here */
}


Now, somewhat obviously, this is all dependent upon your theme.  I am aware that some out there dislike all the markup Drupal by default creates and has overridden a lot of the standard templates to create leaner markup.

If that's the case in your instance, you should still be to instruct Views to add a class to each row if you want.  This is accessed via the overall Style Settings (where you can also look at each Views template that is used for the particular view).

You could also instruct Views to add a class to each field wrapper.  This is accessed from the config widget by each field.

ADDITION based upon commentary:

The Views template that creates the output of the view-content div is views-view.tpl.php and the code in question is:

&lt;?php if ($rows): ?&gt;
  &lt;div class="view-content"&gt;
    &lt;?php print $rows; ?&gt;
  &lt;/div&gt;
&lt;?php elseif ($empty): ?&gt;
  &lt;div class="view-empty"&gt;
    &lt;?php print $empty; ?&gt;
  &lt;/div&gt;
&lt;?php endif; ?&gt;


so without changing this up, you're right, Views doesn't allow quick and easy preprocessing of the View to insert any other variables into that div's classes.

You could however use Views' preprocessing hooks to create an additional variable so you don't need to create lots of additional templates but rather just one more.

For example, copy views-view.tpl.php to your theme (easiest) or module (requires special Views theme incantations :) and modify it along these lines:

&lt;?php if ($rows): ?&gt;
  &lt;div class="view-content &lt;?php print $my_special_content_class; ?&gt;"&gt;
    &lt;?php print $rows; ?&gt;
  &lt;/div&gt;
&lt;?php elseif ($empty): ?&gt;
  &lt;div class="view-empty"&gt;
    &lt;?php print $empty; ?&gt;
  &lt;/div&gt;
&lt;?php endif; ?&gt;


and then create a views preprocess hook along these lines:

function YOURTHEMEORMODULE_preprocess_views_view(&amp;$vars) {

  $name=$vars['name'];
  $display_id=$vars['display_id'];

  if ($name=='VIEWYOUWANT' &amp;&amp; $display_id=='DISPLAYYOUWANT') {
    $vars['my_special_content_class']='FOO';
  } else {
    $vars['my_special_content_class']=''; // so we don't have to isset() or !empty() it in our template :)
  }

}


Save everything and clear your theme cache and now you should be on your way.

SECOND ADDITION:

Upon further thought, and a 'doh!' moment, you can do this without a template at all in preprocess like this:

function YOURTHEME_preprocess_views_view(&amp;$vars) {

  $name=$vars['name'];
  $display_id=$vars['display_id'];

  if ($name=='VIEWYOUWANT' &amp;&amp; $display_id=='DISPLAYYOUWANT') {
    $vars['rows']='&lt;div class="FOO"&gt;' . $vars['rows'] . '&lt;/div&gt;';
  }

}


if you don't mind another wrapped div in there.  And, I think you will need to/should do this in your theme instead of a module so you make sure this happens in the right order, eg, you want this to happen after Views is all said and done with things, and the theme hooks always run after the module hooks.