By betovarg on
Hi all,
Just wanted to share a template for views-view-grid.tpl.php, small simple mod that removes the table and has the markup in divs. So here it is:
<?php
reset($rows);
$gridsize = count($rows[0]);
?>
<?php if (!empty($title)) : ?>
<h3 class='grid-title'><?php print $title; ?></h3>
<?php endif; ?>
<div class="views-view-grid grid-<?php print $gridsize ?>">
<?php foreach ($rows as $row_number => $columns): ?>
<?php
$row_class = 'row-' . ($row_number + 1);
if ($row_number == 0 && count($rows) > 1) {
$row_class .= ' row-first';
}
elseif (count($rows) == ($row_number + 1)) {
$row_class .= ' row-last';
}
?>
<div class="<?php print $row_class; ?>">
<?php foreach ($columns as $column_number => $item): ?>
<div class="gridCol <?php print 'col-'. ($column_number + 1); ?>">
<?php if ($item): ?>
<div class='grid-item'>
<?php print $item; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
I added some extra code to hide
when there are no post to show, useful if you are theming directly in that div (dont want the item to show empty if you use some padding or margins with a background).
Comments
Nice Template
Hi,
Thanks for this.
Vikrant R
Thanks!
Just what I needed. thanks!
I like it!
Thanks for sharing.
Here is an alternate I found
Here is an alternate I found as part of a twitter bootstrap theme.
This is similar to what Views
This is similar to what Views Responsive Grid does. The module gives a little more options in the Views UI, but this template should be more than enough if you don't want the settings or another module just to override the default table-based template.