2
votes

I have two views in a Drupal page with the following structure:

<div>
    <div>Some content</div>
    <div> View 1 </div>
    <div> View 2 </div>
</div>

Now I want a wrapper div covering the two views:

<div>
    <div>Some content</div>
    <div class="wrapper">
        <div> View 1 </div>
        <div> View 2 </div>
    </div>
</div>

What is the best and easiest way to do this?

3
How do you inject the views to the page? - Henrik Opel

3 Answers

1
votes

A cleaner way would be to use the views_embed_view function to get the output from the two views, which you then wrap in a div.

Where to put this code and how to do it, would depend on how you are doing things now. You could create a block for it and gain the flexibility of blocks.

0
votes

You'll want to create a custom .tpl file for this. It would be something like, but not exactly:

views-view-viewname.tpl.php

To find the file name, edit the views then look under Basic Settings > Theme.

0
votes

You can also use Views attachments (Google around to figure out how to make them). So make View 1 a normal view and attach View 2 to appear after View 1. You will get a wrapper div around both the views.