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

 
Năm 2011 - Tiền đổ và SEO nhiều hơn

Năm 2011 - Tiền đổ và SEO nhiều hơn

Như một kết quả tất yếu về xu hướng và nhận thức kinh tế xã hội, giá trị mà các công ty Web đổ vào SEO

Giới thiệu 4 Social Sharing Modules cho Drupal

Giới thiệu 4 Social Sharing Modules cho Drupal

If you don't give your site visitors an opportunity to share your webpages, you're missing out on an opportunity for others to hear about your great content.

Tính năng tìm kiếm mới: Google Application Search

Tính năng tìm kiếm mới: Google Application Search

Today I spotted a new search option on Google – “Applications”. Not sure if I’ve been blind or this is a completely new option in the “More” section.

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

 

Diet con trung