1

I have a view which uses "unformatted list" as it's output format.

<div class="view view-featured-causes-view view-id-featured_causes_view view-display-id-block view-dom-id-961c974a51410cb04cdd2a2be4f3c589">
<div class="view-content">...</div></div>

Now I want these divs to be stripped.

I tried the solution in this answer, but I just want to change the format. I do not want to use Semantic views as that does not help at all in my case.

I manually created a views theme (copying unformatted list) and changing its code as:

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

to:

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
    </div></div><?php print $row; ?><div><div>
<?php endforeach; ?>

but that deeply craps out my overall design.

What is the most appropriate and simplest way to do this?

3
  • 1
    @KrishnaMohan : I don't this this is a duplicate, if I read the OP correctly. The other question talks about rows wrapper elements, this one about the outer/view wrapper divs. Aug 29, 2016 at 9:01
  • @KrishnaMohan as I mentioned in the question, that answer did not solved my problem. Aug 29, 2016 at 9:06
  • of course, I did. please read my question. I mentioned that in there already :( Aug 29, 2016 at 9:12

1 Answer 1

2

You should override the views-view.tpl.php, not the views-view-unformatted.tpl.php.

The two divs you mention are originating from sites/all/modules/views/theme/views-view.tpl.php, check out lines 30 and 55.

If you copy this over to your theme's templates folder, and rename to be specific to your page/block display, you can remove that part of the template's code and you should get what you need.

cp sites/all/modules/views/theme/views-view.tpl.php sites/all/themes/your_theme/templates/views/views-view--your-ul-page.tpl.php

N.B.: This is exactly what the other post's accepted answer is doing in the first part, before going into Semantic Views configuration, you can ignore that part. Here is a modified/simpler version of the code snippet from that answer, for quick reference:

<div class="<?php print $classes; ?>">     // 30: delete this line
  <?php print render($title_prefix); ?>
  <?php if ($title): ?>
[...]
<?php if ($rows): ?>
    <div class="view-content">  // 55: delete this line, 
      <?php print $rows; ?>
    </div>                      // 57: delete this line
  <?php elseif ($empty): ?>
[...]
</div><?php /* class view */ ?> // 90: delete the div from this line

Good luck!

1
  • sure thing, I really think this is not a duplicate btw. Good thing you mentioning the other answer in your OP. Cheers! Aug 29, 2016 at 9:24

Your Answer

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

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