0

I have a views which rendered html like this

<div class="content">
<div class="row-1">Some Text here</div>
<div class="row-2">Some Text here</div>
<div class="row-3">Some Text here</div>
</div>

Now I want to wrap the rows using a wrapper div like so.

<div class="content">
<div class="wrapper-1">
<div class="row-1">Some Text here</div>
<div class="row-2">Some Text here</div>
<div class="row-3">Some Text here</div>
</div>
</div>
2
  • What's your question exactly? Where are you stuck?
    – Clive
    Oct 25, 2014 at 10:24
  • @Clive : I want to add a wrapper div from views admin panel Oct 26, 2014 at 12:45

2 Answers 2

1

Assuming you know how to override theme templates (that would be a separate question) you can override the views_view_unformatted.tpl.php template and make your override something like this:

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<div class="wrapper-1">
  <?php foreach ($rows as $id => $row): ?>
    <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"'; } ?>>
      <?php print $row; ?>
    </div>
  <?php endforeach; ?> 
</div>

You could also override the views-view.tpl.php template instead and in the part that says:

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

do something like

<?php if ($rows): ?>
  <div class="view-content">
    <div class="wrapper-1">
      <?php print $rows; ?>
    </div>
  </div>
<?php elseif ($empty): ?>
  <div class="view-empty">
    <?php print $empty; ?>
  </div>
<?php endif; ?> 

It's up to you which way you want to do it.

2
  • I want to add wrapper div from admin panel. Oct 26, 2014 at 12:43
  • Sorry, your question didn't really specify that. It says drupal 7 views and then says wrapper around rows of unformatted list. You should add more specific information to your question. Unfortunately I don't have time for answering any more questions for at least the next few days.
    – rooby
    Oct 26, 2014 at 12:53
0

You can go to your view under format click on format settings see List section, select one of the list types and type name of your class. li, ol, de tag will be placed where you want it.

1
  • The question isn't about making a html list it is about adding a wrapper div to an unformatted list view.
    – rooby
    Oct 25, 2014 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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