I want to wrap these elements in one div (this div should be before div class = row) but I don't know where to add this div

enter image description here


<div class="col col-lg-4 col-md-4 col-sm-4 col-xs-6 ">
            <div class = "my_custom> 
             <div class="views-field views-field-title">
             <div class="views-field views-field-field-image">
             <div class="views-field views-field-field-product-reference">
             <div class="views-field views-field-commerce-price">

I am using Bootstrap theme and views_bootstrap module.

  • I use drupal 7 version
    – rick1
    Jul 22 '16 at 9:07
  • Are you using the Views Bootstrap module?
    – No Sssweat
    Jul 22 '16 at 9:07
  • yes I use this module and I use bootstrap sub-theme as well
    – rick1
    Jul 22 '16 at 9:09
  • The div you want to add before row, where does it end? does it wrap the entire view? or just the row?
    – No Sssweat
    Jul 22 '16 at 9:10
  • it will wrap all row
    – rick1
    Jul 22 '16 at 9:14

You could create a template for your view fields:


Example: views-view-fields--hello-world--block-1.tpl.php

In template file you add code like this, this is just an example, modify as you need:

<div class="example"> 
 <div class="row">
   <div class="col-xs-6 col-sm-4">
     <div class="my_custom"> 
       <?php echo $fields["title"]->content . 
                  $fields["body"]->content . 
                  $fields["field_product_reference"]->content .

Place your template file in /sites/all/themes/YOURTHEME/templates folder and clear/flush cache to see changes.

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Clive
    Jul 22 '16 at 13:29

In case you want a simpler answer with no coding needed just use Views Fieldset. So install the module, add your row class on the view (Format > Settings > Row Class).

Then add a fieldset (Fields > Add > Global: Fieldset), in the settings of the fieldset choose div and to the HTML classes add the column classes. Don't forget to to go to Fields > Rearrange and put your fields in the fieldset group.

That's it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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