Hướng dẫn Drupal "Views Grid Style Format" responsive

Hướng dẫn Drupal "Views Grid Style Format" responsive

Hướng dẫn Drupal "Views Grid Style Format" responsive

You probably used the Views' famous Grid Style Format to easily output items in a grid. You also probably noted that the Grid Style Format uses tables, which is not responsive, and is does not play well with Twitter's Bootstrap UI library.

Here's a quick hack override to make your favorite Grid Style Format, responsive and play well without any need for extra CSS.

What is the trick?

Easy! The whole purpose is to replace the html tags in views-view-grid.tpl.php to us <div> instead of <table>, and Bootstrap's grid instead of <tr> and <td>.

How this is done?

  1. Override views-view-grid.tpl.php in your theme with the code below.
  2. Make sure you choose the Grid Style Format from your view format settings.
<?php if (!empty($title)) : ?>

  <h3><?php print $title; ?></h3>

<?php endif; ?>

<div class="<?php print $class; ?>"<?php print $attributes; ?>>

  <?php if (!empty($caption)) : ?>

    <caption><?php print $caption; ?></caption>

  <?php endif; ?>


  <div>

    <?php foreach ($rows as $row_number => $columns): ?>

      <?php

        $columns_count = count($columns);

        $span_number = round(12 / $columns_count);

       ?>

      <div <?php if ($row_classes[$row_number]) { print 'class="row-fluid ' . $row_classes[$row_number] .'"';  } ?>>

        <?php foreach ($columns as $column_number => $item): ?>

          <div <?php if ($column_classes[$row_number][$column_number]) { print 'class="span' . $span_number . ' ' . $column_classes[$row_number][$column_number] .'"';  } ?>>

            <?php print $item; ?>

          </div>

        <?php endforeach; ?>

      </div>

    <?php endforeach; ?>

  </div>

</div>
Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Cách làm picture and Image Replace trong Drupal 7

Cách làm picture and Image Replace trong Drupal 7

The Picture module is a backport of Drupal 8 Responsive Image module. It allows you to select different images to be loaded for different devices and resolutions using media queries and Drupal’s image styles

Google Calendar Thêm Tính Năng Gợi Ý Thời Gian Cho Sự Kiện

Google Calendar Thêm Tính Năng Gợi Ý Thời Gian Cho Sự Kiện

Tạo một sự kiện hay một lịch họp không khó nhưng lựa chọn được thời gian thích hợp sau cho tất cả khách mời đều có thể tham gia ...

Hướng dẫn tạo 1 Personalized Content Feeds trong Drupal 7

Hướng dẫn tạo 1 Personalized Content Feeds trong Drupal 7

One of our members wanted to allow users to create customized information feeds in Drupal. In this tutorial, we'll show you how to do that. We'll demonstrate how to allow users to view only certain types of content.

Công ty diệt chuột T&C

 

Diet con trung