In Bootstrap Thumbnails:

Currently you can only define the number of columns for large devices. It should be possible to allow for which devices you want to add a col-**-** class. For example you may want to apply:

col-xs-12 col-sm-6 col-md-4 col-lg-3

OR

col-xs-12 col-md-3

I will follow up with a patch.

CommentFileSizeAuthor
#107 interdiff-2203111-105-107.txt5.22 KBjoelstein
#107 views_bootstrap-columns-per-device-2203111-107.patch25.07 KBjoelstein
#106 Screen Shot 2016-03-30 at 6.42.35 AM.png44.96 KBjoelstein
#105 device_size_support_in-2203111-105.patch24.4 KBsylus
#92 views_bootstrap-breakpoint-control-2203111-92-7.x.patch24.45 KBadam-delaney
#86 snapshot12.png49.56 KBkrystalcode
#74 views_bootstrap-thumbails-columns-per-device-size-2203111-66.patch24.43 KBkrystalcode
#56 views_bootstrap-thumbails-columns-per-device-size-2203111-54.patch24.39 KBkrystalcode
#54 missing-visible-lg-block.png254.93 KBbsztreha
#50 views_bootstrap-thumbails-columns-per-device-size-2203111-47.patch24.38 KBkrystalcode
#46 views_bootstrap_devpatched_screen.png52.54 KBbsztreha
#43 views_bootstrap-thumbails-columns-per-device-size-2203111-40.patch14.12 KBakalam
#40 views_bootstrap-thumbails-columns-per-device-size-2203111-40.patch14.12 KBJurriaanRoelofs
#39 views_bootstrap-thumbails-columns-per-device-size-2203111-39.patch14.11 KBJurriaanRoelofs
#38 views_bootstrap-thumbails-columns-per-device-size-2203111-38.patch14.23 KBJurriaanRoelofs
#36 views_bootstrap-thumbails-columns-per-device-size-2203111-36.patch14.24 KBvasike
#26 views_bootstrap-thumbails-columns-per-device-size-2203111-26.patch13.32 KBnicholas.alipaz
#15 views_bootstrap-2203111-thumbails-columns-per-device-size.patch13.25 KBSteven Jones
#8 views_bootstrap-thumbails-columns-per-device-size-2203111-8.patch19.45 KBJurriaanRoelofs
#4 views_bootstrap-thumbails-columns-per-device-size-2203111-4.patch6.48 KBkrystalcode
#1 views_bootstrap-thumbails-columns-per-device-size-2203111-1.patch4.96 KBkrystalcode
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

krystalcode’s picture

And here is the patch.

UPDATE: How this works is that you have to define at least the number of columns for the extra small device size. If a setting is not defined for a larger size it will not produce a css class for it, which for bootstrap will mean that it will inherit the number of columns from the smaller sizes defined.

For example, setting XS to 1 column and MD to 3 columns will produce the following classes:

col-xs-12 col-md-4

which will result 1 column for XS and SM and 3 columns for MD and LG device sizes, as defined by bootstrap grid system.

vlooivlerke’s picture

I get these errors when viewing a view with thumbnail bootstrap settings set to default.

Notice: Undefined variable: columns in template_preprocess_views_bootstrap_thumbnail_plugin_style() (line 13 of /modules/contrib/views_bootstrap/templates/thumbnail/theme.inc).
Warning: Division by zero in _views_bootstrap_split_rows() (line 30 of /modules/contrib/views_bootstrap/views_bootstrap.module).
Warning: Division by zero in _views_bootstrap_split_rows() (line 31 of /modules/contrib/views_bootstrap/views_bootstrap.module).

This is the output:

<div class="views-bootstrap-thumbnail-plugin-style" id="views-bootstrap-thumbnail-1">
  
          <div class="row">
                  <div class="col col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div class="thumbnail">
           ........
tr33m4n’s picture

I also get the same errors, any updates?

krystalcode’s picture

Hey,

I had a look. Views needs a common number of columns option that will define how the HTML will be structured. regardless of the device size. This means, how many columns will be rendered per row for horizontal alignment or how many columns for vertical alignment.

I have re-rolled the patch to add an extra option for that, while keeping the other options for defining the css classes per device size. Please test and let me know.

If you are interested for a patch that outputs all columns in a single row and the number of columns shown on the screen are defined purely by the css classes options, have a look here: https://drupal.org/node/2203125

If you are interested in combining both approaches, let me know and I can roll a patch that combines both.

ngreenup’s picture

What about the grid format. The patch added columns per device for thumbnails but not for grid.

krystalcode’s picture

@ngreenup you may be interested in that issue: https://drupal.org/node/2056963

sw3b’s picture

Status: Active » Reviewed & tested by the community

Excellent Work ! Thanks... work like a charm !

JurriaanRoelofs’s picture

Title: Device size support in Bootstrap Thumbnails column classes » Device size support in Bootstrap Thumbnails and Grid column classes
FileSize
19.45 KB

I updated the patch to do the same for the grid style plugin. I'll link from the other issue because the code in that issue is less performant/solid.

tr33m4n’s picture

Superb cheers bud, will test asap

vlooivlerke’s picture

Patch does not apply cleanly

views-bootstrap-thumbnail-plugin-style.tpl:15

<div class="col col-lg-<?php print $column_type ?>">
to
<div class="<?php print $col_classes ?>">

thanks, thumbnail and carousel works well.

testing the rest

vlooivlerke’s picture

Spoke too soon.

sorry, media work well! not thumbnail

I get this error

Notice: Undefined variable: columns in template_preprocess_views_bootstrap_thumbnail_plugin_style() (line 13 of /sites/all/modules/contrib/views_bootstrap/templates/thumbnail/theme.inc).

Warning: Division by zero in _views_bootstrap_split_rows() (line 30 of /sites/all/modules/contrib/views_bootstrap/views_bootstrap.module).
Warning: Division by zero in _views_bootstrap_split_rows() (line 31 of /sites/all/modules/contrib/views_bootstrap/views_bootstrap.module).

extra small screen 1
small screen 2
meduim 3
large 4
desktop 6

no matter what settings i put in it only gives me 2 thumbnails on desktop large and medium and small. Extra small works and gives me 1

vlooivlerke’s picture

Grid does not work.

You only have an option to set the desktop size, no other screen sizes in between like thumbnail.

I tested all the other features this module offers and it is only thumbnail and grid that is not working, the rest works well so it could be close to put a stable bootstrap 3 out

thanks

tr33m4n’s picture

I've tested the patch, and apart from it not applying cleanly to the templates (fixed by comparing patch.rej) grid seems to work for me so far :) Good work

Christopher Riley’s picture

I would really like to get this committed as I think it is a important bit of functionality and would like to see it be made "official".

Steven Jones’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
13.25 KB

Here's a re-roll of #8 against the latest 7.x-3.x.

Looks like we need more reviews of the patch before we can consider it ready.

Christopher Riley’s picture

#15 seems to work like a champ for me thank you so much for the patch. This functionality really adds a great deal to the module.

that0n3guy’s picture

I can verify that this works.

This will break your existing tpl files (example: views-bootstrap-grid-plugin-style--myview-name.tpl.php).

rtdean93’s picture

#15 works great on the April 27 release.

vlooivlerke’s picture

Yes it works perfect. Thanks

Anonymous’s picture

Plase add this to official next release. Very useful!

bmodesign’s picture

#15 worked on the April 27 release as well. Thank you for the patch!

Steven Jones’s picture

Does anyone who has reviewed #15 feel brave enough to change the issue status to RTBC?

vlooivlerke’s picture

Status: Needs review » Reviewed & tested by the community

Yes, I am brave.

Works like a charm and has moved it to production.
Have a look at my test site (this link will only live a few days)
It has a Carousel, Thumbnail, Grid, and Media views in it.
Only thing I have not tested is the export and import function of a bootastrap view.

friera’s picture

It works for me, but I can't export/import the options.

How can I export this configuration to use with the features module ?

Thank you

Steven Jones’s picture

@friera if you export the view in the normal features way, you should also be exporting the config.

nicholas.alipaz’s picture

Here is a new version that will export properly. The issue was that the options were not defined (with defaults) in the option_definition() function.

nicholas.alipaz’s picture

Status: Reviewed & tested by the community » Needs review
tr33m4n’s picture

This seems to work except when resizing the browser window to the point that it changes the amount of results per row, things get a little jumbled up, for example one row would have 3 results on it (expected) then the next would have 1 result and so on...

Anyone know why this is happening?

Cheers

vlooivlerke’s picture

get the same result

try switching between horizontal and vertical alignment.

this does not fix, but is a bit better

vlooivlerke’s picture

This is how it works

it must be in dividable pairs, if that make sence

lets say large = 8

then medium must be = 4

and small = 2

OR

large = 6

medium = 3

small =1

If it is

Large = 6

medium = 4

small = 3

and small= 2

This will make the rows to display unevenly.

So this is not a bug I guess

tr33m4n’s picture

Ah, thanks for that, will try asap

tr33m4n’s picture

Does not work with large=4 medium=2 small=1 :S

JurriaanRoelofs’s picture

Path 26 works great for me, including export of grid settings with features, thanks for your update Nicholas

rcodina’s picture

Patch on commment #26 works for me too

samuelsov’s picture

As described by taote in comment https://www.drupal.org/node/2056963#comment-8355529, i think we need to use clearfix instead of row if we want the grid to work with whatever number of rows depending on the screen size.

There should be only one row containing all the items and the line break will depends on where we set the clearfix.

See http://getbootstrap.com/css/#grid-responsive-resets for an example.

Another more complex example for a 3 columns, then 2 columns, then 1 column, the result should be something like :

<div class="row">
  <div class="col-xs-12 col-sm-6 col-md-4">col-xs-12 col-sm-6 col-md-4</div>
  <div class="clearfix visible-xs-block"></div>   <!-- clear for xsmall screen only -->

  <div class="col-xs-12 col-sm-6 col-md-4">col-xs-12 col-sm-6 col-md-4</div>
  <div class="clearfix visible-xs-block visible-sm-block"></div>  <!-- clear for xsmall and small screen only -->

  <div class="col-xs-12 col-sm-6 col-md-4">col-xs-12 col-sm-6 col-md-4</div>
  <div class="clearfix"></div> <!-- clear for any screen size -->

    <div class="col-xs-12 col-sm-6 col-md-4">col-xs-12 col-sm-6 col-md-4</div>
  <div class="clearfix visible-xs-block"></div>   <!-- clear for xsmall screen only -->

  <div class="col-xs-12 col-sm-6 col-md-4">col-xs-12 col-sm-6 col-md-4</div>
  <div class="clearfix visible-xs-block visible-sm-block"></div>  <!-- clear for xsmall and small screen only -->

  <div class="col-xs-12 col-sm-6 col-md-4">col-xs-12 col-sm-6 col-md-4</div>
  <div class="clearfix"></div> <!-- clear for any screen size -->
</div>
vasike’s picture

Component: User interface » Code
Status: Needs review » Needs work
FileSize
14.24 KB

there is re-roll for patch from #26 as it won't be applied because of the latest changes to repository.

probably there should be also some other changes for the template files according with the latest commits.
Si i think it "Needs work".

vlooivlerke’s picture

I would like to see @samuelsov solution in action. Would this be the best place to get it started?

JurriaanRoelofs’s picture

I discovered an issue with the patches; they add a 'col' class alongside the col-xx-n classes which is not supported in Bootstrap 3. This col class caused problems in some themes that I maintain. Here is a reroll of #36 without the 'col' added.

JurriaanRoelofs’s picture

Also removed the

wrapper that is not used and also conflicts with some themes I maintain.
JurriaanRoelofs’s picture

torgosPizza’s picture

This seems to work well for me. Thanks for working on it!

Now to figure out how to get the floats cleared correctly for different sizes...

sylus’s picture

So what is left on this issue to get this marked RTBC?

akalam’s picture

Status: Needs work » Needs review
FileSize
14.12 KB

#20 does not appy for me. Adding a white space at the bottom works

bsztreha’s picture

#43 applied to dev, and looks work fine
but i see now more functionality as needed

I think this functionality is perfect. "Class prefix" is useless, because you can select only one screen size

vlooivlerke’s picture

This current patch is not the right direction.
It does not give you device size support for grid and thumbnail as stipulated in bootstrap. This patch does not implement clearfix.

Here is a working model. Just copy and replace to take it for a quick spin.

views-bootstrap-grid-plugin-style.tpl

<?php
/**
 * @file views-bootstrap-grid-plugin-style.tpl.php
 * Default simple view template to display Bootstrap Grids.
 *
 *
 * - $columns contains rows grouped by columns.
 * - $rows contains a nested array of rows. Each row contains an array of
 *   columns.
 * - $column_type contains a number (default Bootstrap grid system column type).
 * - $class_prefix defines the default prefix to use for column classes.
 *
 * @ingroup views_templates
 */
?>

<?php if (!empty($title)): ?>
  <h3><?php print $title ?></h3>
<?php endif ?>

<div id="views-bootstrap-grid-<?php print $id ?>" class="<?php print $classes ?>">
  <?php if ($options['alignment'] == 'horizontal'): ?>

    <?php foreach ($items as $row): ?>
      <div class="row">
<?php $colsmd=1; $colslg=1; $colssm=1; $colsxs=1; ?>
        <?php foreach ($row['content'] as $column): ?>
 <div class="col col-lg-<?php print $options['col_lg'] ?> col-md-<?php print $options['col_md'] ?> col-sm-<?php print $options['col_sm'] ?> col-xs-<?php print $options['col_xs'] ?>">
            <?php print $column['content'] ?>
          </div>
<?php  
              $colsrowlg = $colslg * $options['col_lg']; 
              if ($colsrowlg==12){
                  $colslg=1;?> 
			  	<div class="clearfix visible-lg"></div>
			  <?php
              }
              else
                  $colslg++; 
          ?>
         <?php  
              $colsrowmd = $colsmd * $options['col_md']; 
              if ($colsrowmd==12){
                  $colsmd=1;?> 
			  	<div class="clearfix visible-md"></div>
			  <?php
              }
              else
                  $colsmd++; 
          ?>
          <?php  
              $colsrowsm = $colssm * $options['col_sm']; 
              if ($colsrowsm==12){
                  $colssm=1;?> 
			  	<div class="clearfix visible-sm"></div>
			  <?php
              }
              else
                  $colssm++; 
          ?>
          <?php  
              $colsrowxs = $colsxs * $options['col_xs']; 
              if ($colsrowxs==12){
                  $colsxs=1;?> 
			  	<div class="clearfix visible-xs"></div>
			  <?php
              }
              else
                  $colsxs++; 
          ?>
        <?php endforeach ?>
      </div>
    <?php endforeach ?>

  <?php else: ?>

    <div class="row">
      <?php foreach ($items as $column): ?>
        <div class="col <?php print $class_prefix ?>-<?php print $column_type ?>">
          <?php foreach ($column['content'] as $row): ?>
            <?php print $row['content'] ?>
          <?php endforeach ?>
        </div>
      <?php endforeach ?>
    </div>

  <?php endif ?>
</div>

Please note the clearfix in the code above. Thanks to taote

You will need to copy and replace the next 2 files, to make it work.

/templates/grid/theme.ini

<?php

/**
 * Implementation of template preprocess for the view.
 */
function template_preprocess_views_bootstrap_grid_plugin_style(&$vars) {
  $view     = $vars['view'];
  $options  = $view->style_plugin->options;
  $horizontal = ($options['alignment'] === 'horizontal');

  $columns = $options['columns'];

  // Split items by rows and columns.
  $vars['items'] = _views_bootstrap_split_rows($vars, $columns, $horizontal);
  $vars['column_type'] = 12 / $columns;
  $vars['class_prefix'] = $options['class_prefix'] ?: 'col-sm';
}

and then

plugins/grid/views_bootstrap_grid_plugin_style.ini

<?php
/**
 * @file
 * Definition of views_bootstrap_plugin_style.
 */

/**
 * Class to define a style plugin handler.
 */
class ViewsBootstrapGridPluginStyle extends views_plugin_style {
  /**
   * Definition.
   */
  public function option_definition() {
    $options = parent::option_definition();
    $options['alignment'] = array('default' => 'horizontal');
    $options['columns'] = array('default' => 3);
    $options['col_lg'] = array('default' => 3);
    $options['col_md'] = array('default' => 4);
    $options['col_sm'] = array('default' => 6);
    $options['col_xs'] = array('default' => 12);
    $options['class_prefix'] = array('default' => 'col-sm');
    return $options;
  }

  /**
   * Form.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    $form['alignment'] = array(
      '#type' => 'radios',
      '#title' => t('Alignment'),
      '#options' => array(
        'horizontal' => t('Horizontal'),
        'vertical' => t('Vertical'),
      ),
      '#description' => t('Horizontal alignment will place items starting in the upper left and moving right.
      Vertical alignment will place items starting in the upper left and moving down.'),
      '#default_value' => $this->options['alignment'],
    );

    $options = array(1, 2, 3, 4, 6, 12);

    $form['columns'] = array(
      '#type' => 'select',
      '#title' => t('Number of columns'),
      '#default_value' => $this->options['columns'],
      '#description' => t('Number of columns rendered per row.'),
      '#options' => array_combine($options, $options),
      '#required' => TRUE,
    );
    $form['col_lg'] = array(
      '#type' => 'select',
      '#title' => t('Large devices'),
      '#default_value' => $this->options['col_lg'],
      '#description' => t('col-lg-*'),
      '#options' => array_combine($options, $options),
      '#required' => TRUE,
    );
    $form['col_md'] = array(
      '#type' => 'select',
      '#title' => t('Medium devices'),
      '#default_value' => $this->options['col_md'],
      '#description' => t('col-md-*'),
      '#options' => array_combine($options, $options),
      '#required' => TRUE,
    );
    $form['col_sm'] = array(
      '#type' => 'select',
      '#title' => t('Small devices'),
      '#default_value' => $this->options['col_sm'],
      '#description' => t('col-sm-*'),
      '#options' => array_combine($options, $options),
      '#required' => TRUE,
    );
    $form['col_xs'] = array(
      '#type' => 'select',
      '#title' => t('Extra small devices'),
      '#default_value' => $this->options['col_xs'],
      '#description' => t('col-xs-*'),
      '#options' => array_combine($options, $options),
      '#required' => TRUE,
      '#default_value' => $this->options['columns'],
    );

    $form['class_prefix'] = array(
      '#type' => 'select',
      '#title' => t('Class prefix'),
      '#description' => t('Defines the default prefix to use for column classes.'),
      '#default_value' => $this->options['class_prefix'],
      '#required' => TRUE,
      '#options' => array(
        'col-xs' => t('Extra Small'),
        'col-sm' => t('Small'),
        'col-md' => t('Medium'),
        'col-lg' => t('Large'),
      ),
    );
  }
}

This above code is a bit messy but works.

Now to set your grid settings to something like this.

Number of columns 6
Large devices 4
Medium devices 6
Small devices 4
Extra small devices 12
Class prefix meduim

This will give you a 3 columns grid on large
and a 2 columns grid on meduim
and 1 columns grid on extra small

aastrong’s picture

Going to try the patch from @vlooivlerke - Hoping to get a patch RTBC.

aastrong’s picture

Havnt been able to try and create a patch yet ( been sick )
Will try to get to it this week.

krystalcode’s picture

Hi all,

Using multiple rows without clearfix divs (as the current patch does), single row with clearfix divs, or single row without clearfix divs, are all valid Bootstrap grid implementations and examples for all can be found in Bootstrap documentation. What we therefore need is to provide options so that the developer or site builder can choose from.

I have re-written the patch with the following major changes (horizontal alignment):

- Added a value "Single row" in the "Number of columns" option for horizontal alignment. When selected all columns will be rendered within one row.
- Added an option "Clear columns per device size", visible when "Single row" is selected. When checked clearfix divs will be added as required.
- Since with these changes the "Number of columns" option has diverged even more between horizontal/vertical alignments, I have separated them.
- The code that calculates the classes and distributes the items in rows/columns has been refactored. Functions have been separated for vertical and horizontal alignment for better readability and avoiding spaghetti code.
- Since this functionality is shared by more than one plugins (Grid and Thumbnails), some refactoring was done to avoid duplicating code in both plugins.

The defaults this patch provides are "Single row" with "Clear columns per device size" enabled. I believe this is the case that @samuelsove and @vlooivlerke discussed.

Vertical alignment has not changed, apart from providing a default of 4 columns.

Calculation of the clearfix divs in this patch happens as follows. Say we have 7 results, with 1 column for xs, 2 columns for sm, 3 columns for md, and 4 columns for lg device sizes. The result will be:

<div class="row">
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"></div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"></div>  
  <div class="clearfix visible-sm-block"></div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"></div>
  <div class="clearfix visible-md-block"></div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"></div>
  <div class="clearfix visible-sm-block"></div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"></div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"></div>
  <div class="clearfix visible-sm-block"></div>
  <div class="clearfix visible-md-block"></div>
  <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"></div>
</div>

Please review & test and let me know if everything works!

andjsmit’s picture

#50 is working for me. Provides a much needed feature. Hope to see it committed soon.

Christopher Riley’s picture

Patch worked for me on a fresh copy of dev although I did have to go back and resave a couple of views. I say please lets get this committed.

maxplus’s picture

Wow,

very nice feature, #50 works great for me on the current dev-version

Thanks!

bsztreha’s picture

FileSize
254.93 KB

I tried, but i found one bug on lg view mode. I've attached the explination

Settings for LG is 6 grid

maxplus’s picture

Correct, I have the same issue with lg mode, I did not see it in the first place...
=> my grid is set to 3 columns in lg mode (so col-lg-4)

krystalcode’s picture

Thanks for spotting this, here is the patch including a quick fix. Let me know if that works.

bsztreha’s picture

#56 Looks good! Thanks for quick reply.

maxplus’s picture

Hi,

thanks for the quick fix!

My settings are as follows:
- Number of columns per views row: Single row (+clear columns per device size checked)
- Number of columns for extra small devices : 2
- Number of columns for small devices: 3
- Number of columns for medium devices: 3
- Number of columns for large devices: 3

Maybe interesting for others, you need to keep the setting "Number of columns per views row" to "Single row"
=> if I change this to some other setting, I get empty spots in my grid

gge’s picture

Hello,

Can somebody please provide a patch that can be applied against the latest dev version?

Thank you

krystalcode’s picture

Patch 56 was created against the latest dev version, did you have any specific issue with it?

JurriaanRoelofs’s picture

side-note: I used this module and issue as a reference in an article about paid modules in Drupal:
http://www.sooperthemes.com/drupal-blog/whats-your-opinion-premium-drupa...
.. because there is a paid module in codecanyon that has the functionality we want here nicely worked out: http://codecanyon.net/item/bootstrap-grid-drupal-7-views-grid/6732197 . Video demo: https://www.youtube.com/watch?v=jWfYKdCEpOc

gge’s picture

@krystalcode

I just downloaded 7.x-3.1+24-dev and patch #56 can be applied only to plugins/grid/views_bootstrap_grid_plugin_style.inc
All files bellow can't be patched:

plugins/thumbnail/views_bootstrap_thumbnail_plugin_style.inc
templates/grid/theme.inc
templates/grid/views-bootstrap-grid-plugin-style.tpl.php
templates/thumbnail/theme.inc
templates/thumbnail/views-bootstrap-thumbnail-plugin-style.tpl.php
views_bootstrap.module

All I get from Netbeans is a window saying "The patch cannot be applied in the selected context"...

Thanks

krystalcode’s picture

Hi @gge,

I've tested the patch again and it applies cleanly on the latest dev version. There might be something that you're doing wrong on the way you're applying the patch? Have a look at this https://www.drupal.org/node/1139226#comment-6681748.

rcodina’s picture

@gge I also cleanly applied patch on #56 into 7.x-3.1+24-dev version of module (I use a terminal under mac os).

The patch seems to work fine so far.

gge’s picture

Hi,

Using the terminal I was finally able to apply the patch. Don't know why I couldn't do it using Netbeans... Now I have to test it.

Thank you,

bsztreha’s picture

@krystalcode
I've realized, that the views export (and features export) doesn't place 'clear_columns' like this:

$handler->display->display_options['style_options']['clear_columns'] = '1';

But if i have changed the form element from checkbox to select, and set options: '#options' => array(0 => t('No'), 1 => t('Yes')), then it looks good

Has anybody this problem?

nicholas.alipaz’s picture

Status: Needs review » Needs work

@bsztreha https://www.drupal.org/node/2203111#comment-8864903 has the answer. No default was set for clear_column. Changing to needs work so that gets fixed.

sylus’s picture

Looking at the patch it appears the defaults were specified? @nicholas.alipaz can you confirm this?

aveach.bfr’s picture

I've been able to apply the patch in 56 to the dev release. It works, but I'm seeing this error:

Notice: Undefined index: columns_horizontal in _views_bootstrap_preprocess_views_style_plugin_prepare_grid_horizontal() (line 125 of /var/www/public/sites/all/modules/views_bootstrap/views_bootstrap.module).

Is there an existing note about this I'm missing?

adam-delaney’s picture

@bsztreha I can confirm this issue with features. The work around is to open the view and re-save the setting. I get the following errors if this workaround has not been performed.

Notice: Undefined index: alignment in _views_bootstrap_preproces_views_style_plugin_prepare_grid() (line 108 of views_bootstrap/views_bootstrap.module).
Notice: Undefined variable: clearfix in include() (line 35 of views_bootstrap/templates/grid/views-bootstrap-grid-plugin-style.tpl.php).
Warning: Invalid argument supplied for foreach() in include() (line 35 of views_bootstrap/templates/grid/views-bootstrap-grid-plugin-style.tpl.php).
Christopher Riley’s picture

I would really like to see this patch get officially applied I am getting tired of patching lol.

taatg37’s picture

#56 has worked for me against the 7.x-3.x-dev released on 2015-Sep-30. It provides the possibilities to specify columns against 4 different device widths.

torgosPizza’s picture

Status: Needs work » Reviewed & tested by the community

The patch in #56 works for me, and works exactly as expected. Please consider committing it to 7.x-3.x!

krystalcode’s picture

I've also tested it again against the latest dev version, applies cleanly and works as expected.

- Problem reported on #69 and #70 happens when the patch is applied and there are existing views that use Grid or Thumbnail. Since the options have changed, there are warnings about options or variables not found. Re-saving the view fixes the problem. Maybe this should be mentioned in the release notes.

- Situation reported on #66 happens because views does not export an option if it has the default value because it is unnecessary. It is not a problem and everything should work just fine. I did make a small change in this patch (#74) so that the clear_columns option is defined as a boolean in order to follow the same definition that checkbox options provided by the views module have.

- I've applied the same sensible defaults to Grid and Thumbnails, not sure why they were different.

After these, I don't think there is anything holding us from adding this patch to the next release ...

torgosPizza’s picture

Status: Reviewed & tested by the community » Needs review

Thanks for the updated patch! Setting to Needs Review, so others can give it a test drive.

dillix’s picture

Status: Needs review » Reviewed & tested by the community

#74 works great!

waverate’s picture

#74 works great.

Thank you.

HallSL’s picture

I just applied the patch in #74. It seemed to apply cleanly, but when I added it to my site... I got these errors:

Notice: Undefined index: columns in template_preprocess_views_bootstrap_grid_plugin_style() (line 11 of /home/historik/public_html/sites/all/modules/views_bootstrap/templates/grid/theme.inc).
Warning: Division by zero in _views_bootstrap_split_rows() (line 30 of /home/historik/public_html/sites/all/modules/views_bootstrap/views_bootstrap.module).
Warning: Division by zero in _views_bootstrap_split_rows() (line 31 of /home/historik/public_html/sites/all/modules/views_bootstrap/views_bootstrap.module).
Warning: Division by zero in template_preprocess_views_bootstrap_grid_plugin_style() (line 15 of /home/historik/public_html/sites/all/modules/views_bootstrap/templates/grid/theme.inc).
Notice: Undefined index: class_prefix in template_preprocess_views_bootstrap_grid_plugin_style() (line 16 of /home/historik/public_html/sites/all/modules/views_bootstrap/templates/grid/theme.inc).

Where did I go wrong?

Thanks!

waverate’s picture

@HallSL

From #74:

Problem reported on #69 and #70 happens when the patch is applied and there are existing views that use Grid or Thumbnail. Since the options have changed, there are warnings about options or variables not found. Re-saving the view fixes the problem.

HallSL’s picture

@waverate

The errors in #69 and #70 don't seem to be the same errors, different undefined indices, different files and/or different lines. Also the earlier errors don't mention division by zero.

And I did see those comments and deleted the only view I had and recreated it... no joy. Any other ideas?

Thanks,
Hall

krystalcode’s picture

@HallSL

I assume you applied the path against the latest dev version?

HallSL’s picture

Yes, I am/was using the latest version of Views Bootstrap. Indeed, when in views, I saw the desired options to set the number of columns per view port size. Seemed good, but the errors persisted and wouldn't let the view save.

krystalcode’s picture

I'm not sure what you mean "wouldn't let the view save". You should be able to save the view anyway, these errors may happen during rendering.

HallSL’s picture

My bad. The view does save. The errors happen when I try to view the result.

Alexandre360’s picture

Tested the lastest 7.x-3.x dev version and I don't understand the new configuration.

Before, we had the possibility to define the number of columns you want for all the 4 media queries.

Now you can just specify it for one

So how to do somethink like this :

- 4 columns on big screen
- 3 columns on medium screen
- 2 columns on small screen
- 1 column on extra small screen

Before it was possible and It seems it's not now :/ did I miss something ?

krystalcode’s picture

FileSize
49.56 KB

Hi @Alexandre360,

I'm not sure if I understand the issue you're encountering, attached is a screenshot of what you should be seeing in the Bootstrap Group or Bootstrap Thumbnails settings. You certainly can define col-* class per screen.

logsd’s picture

Hi krystalcode,

I have the same behavior described by Alexandre360 in #85 with latest 7.x-3.x dev version, not the one shown in your "snapshot12.png" above.

In short, the latest 7.x-3.x dev version allows to define the "Number of columns" and to choice only one "Class prefix" (xs, sm, md, lg).

adam-delaney’s picture

Status: Reviewed & tested by the community » Needs work

I have tested patch #74 and seeing the new configuration values in views, however if I attempt to package the view in features and deploy the new feature, I must manually save the view for it to work properly. If you are packaging configuration and deploying it using features this becomes a big issue. I feel like this patch still needs work. Here are the errors when deploying new configuration settings without manually saving the view.

Notice: Undefined index: alignment in _views_bootstrap_preproces_views_style_plugin_prepare_grid() (line 108 of [path_to_module]->views_bootstrap.module).
Notice: Undefined variable: clearfix in include() (line 35 of [path_to_template]->views_bootstrap/templates/grid/views-bootstrap-grid-plugin-style.tpl.php).
Warning: Invalid argument supplied for foreach() in include() (line 35 of [path_to_template]->views_bootstrap/templates/grid/views-bootstrap-grid-plugin-style.tpl.php).

adam-delaney’s picture

@logsd and @Alexandre360 , are you applying the patch to the dev version? You must apply the patch to the latest dev in order to see the changes.

adam-delaney’s picture

What I'm noticing when features configuration for the view gets exported, there are 2 missing style_options:

  • ['style_options']['alignment'] = 'horizontal';
  • ['style_options']['clear_columns'] = 0;

I see the options being set in the database in the views_display table -> display options serialized array, however when features exports these options they are missing for the view. I'm not quite sure how ctools exports this configuration so any help would be appreciated.

After further testing, I see that if the configuration for alignment is set to 'vertical', the style_option is exported properly for both alignment and clear_columns.

Thanks.

adam-delaney’s picture

Digging a little deeper I started looking into views export_options() code. I'm using views-7.x-3.11.
[path_to_views_module]/includes/base.inc on line 247

if ($value !== $default) {
  $output .= $indent . $prefix . "['" . implode("']['", $parents) . "'] = ";
  if (isset($definition['bool'])) {
    $output .= empty($storage[$option]) ? 'FALSE' : 'TRUE';
  }
  else {
    $output .= views_var_export($storage[$option], $indent);
  }
  $output .= ";\n";
}

The if ($value !== $default) is not allowing the values for alignment and clear_columns to be exported, oddly enough they get exported for the other values. I see that the other values are all integers, where these values are string and boolean respectively. I wonder if this is part of the issue.

It may be possibly to define an export value for strings and booleans that are in a default state, but we'll have to do some digging.

I'm wondering if this is related to the issue Allow Views export of all style settings (https://www.drupal.org/node/1513198) is having. It doesn't look like they have not solved the issue, but I wanted to document what they have tried.

adam-delaney’s picture

Status: Needs work » Needs review
FileSize
24.45 KB

Breakthrough on getting the features export to work. I was traveling down the wrong path and assuming the option_definition() was not properly defined for exporting the view. The issues lies within getting these style options in the template_preprocess functions. Instead of getting the options from $var['view']->style_options (which appears to be the options that get exported) we should be getting these options from the style plugin array like this $vars['view']->style_plugin->options.

I have attached a patch that has all the code from patch #74 thanks to @krystalcode and also have included the update to the preprocess functions in views_bootstrap.module.

tobiasaldgard’s picture

#92 fixed the things I needed. No bugs as far as I can see.

Thanks @adam-delaney

dillix’s picture

Status: Needs review » Reviewed & tested by the community

#92 Works good!

sylus’s picture

Any chance for an official release with this bundled in anytime soon? :)

aastrong’s picture

#92 is working great for me,
Any chance of this getting pulled into the latest 7.x-3.1 ?

Cheers !

Tyera’s picture

I'm having trouble getting patch #92 applied successfully to my module.
Would anyone be able to share the files for their working version?

adam-delaney’s picture

@Tyera, are you applying the patch against the latest dev?

Tyera’s picture

Yes, I downloaded a fresh version of 7.x-3.x-dev.

sylus’s picture

The patch does work so there is something wrong with your process.

git clone --branch 7.x-3.x https://git.drupal.org/project/views_bootstrap.git
cd views_bootstrap
patch -p1 < views_bootstrap-breakpoint-control-2203111-92-7.x.patch

  patching file plugins/grid/views_bootstrap_grid_plugin_style.inc
  patching file plugins/thumbnail/views_bootstrap_thumbnail_plugin_style.inc
  patching file templates/grid/theme.inc
  patching file templates/grid/views-bootstrap-grid-plugin-style.tpl.php
  patching file templates/thumbnail/theme.inc
  patching file templates/thumbnail/views-bootstrap-thumbnail-plugin-style.tpl.php
  patching file views_bootstrap.module
sylus’s picture

So what are the odds of getting this issue in or at least looked at by the maintainer? Before leverage this patch want to make sure for the most part it is stable and it will likely be merged.

Tyera’s picture

Thank you, yes, I understand that. It would still be really helpful to get a copy of a working version, and help me I am identify where my process is going wrong.

Mile23’s picture

Status: Reviewed & tested by the community » Needs work

+1 on this.

7.x-3.x-dev currently allows you to set the 'default' breakpoint for the thumbnail view format. So it's a little better in dev, allowing you to change the breakpoint where it collapses from the column setting to full-width. I don't see this in 7.x-3.1. I hope we can get a release for this either way...

The patch in #92 does apply against dev, which is good and proper. :-)

+++ b/plugins/grid/views_bootstrap_grid_plugin_style.inc
@@ -32,33 +38,113 @@ class ViewsBootstrapGridPluginStyle extends views_plugin_style {
+      '#description' => t('When this option is selected, clearfix divs will be used to "clear" the columns as needed per device size (see related ') . '<a target="_blank" href="http://getbootstrap.com/css/#grid-example-mixed-complete">' . t('Bootstrap documentation') . '</a>. ' . t('This option applies only when "Single row" is selected for the "Number of columns per view row" option'),

Needs placeholders instead of concatenated strings. https://www.drupal.org/node/322774

Also, missing the closing paren from '(see related'.

zenimagine’s picture

hello thank you for your work. The patch works with grids.
With mignatures it does not work, I have a blank page.
Could you put an archive with files and patch applied?
thank you

sylus’s picture

Status: Needs work » Needs review
FileSize
24.4 KB

Attahing patch based on latest feedback fixing the placeholders issue.

joelstein’s picture

Issue summary: View changes
FileSize
44.96 KB

I'm so glad to discover this patch! It's just what this module needs to make the grid format truly flexible. Thanks to everyone who worked on it.

I tested the grid functionality and it seems to work as advertised. The clearfix support is perfect.

Is there no way to add a custom class per column? I can see that very helpful for styling, for example, to add vertical spacing between the columns as the grid breaks down per breakpoint.

Also, not a huge deal, but in the HTML there's a space before the column classes:

joelstein’s picture

Here's a patch which does the following things:

  • Fixes misspelling in the function name, _views_bootstrap_preproces_views_style_plugin_prepare_grid.
  • Removes extra space in column classes variable.
  • Adds a "column classes" option so we can add arbitrary CSS classes to all columns.
yaach’s picture

I have tried all the patches on this issue, none of them work form me. Latest dev and try to use Bootstrap Grid. The containers only get the following classes: col col-lg.
I spent lot of time trying to get this to work but nothing! Anybody?

aastrong’s picture

@yalegria - have you re-saved your view after applying the patch ? As you will have to change the settings to get the different classes for each breakpoint.
I have tried the most recent patch and it has worked for me,

yaach’s picture

@aastrong - this is my procedure in applying the patch(es):

1. drush en views_download --select
2. Select [1] for the dev option
3. Select (y) to overwrite the current module
4. Download patch under modules/views_bootstrap
5. Apply patch: patch -p1 < patch-file
6. Clear cache
7. Resave my view.

No luck whatsoever.

aastrong’s picture

@yalegria
Hey there, i just re-did the exact same procedure and it worked fine for me.

for #7 - can you click on settings, and tell me what you see ?
Do you see a number of different options instead of the options before the patch ?

Maybe try clicking settings, change the settings, than save.

Thanks and let me know.

yaach’s picture

@aastrong

Settings:

Grouping: none
Alignment: Horizontal
Number of columns per views row: Single Row
Clear columns per device size: checked
Number of columns for extra small devices: 1
Number of columns for small devices: 2
Number of columns for medium devices: 3
Number of columns for large devices: 4

I did try to change the settings, even to Bootstrap Thumbnails where YES it works, but when I use the Bootstrap Grid the classes are not introduced on the DOM. and yes I need to use Bootstrap Grid. Really dont know what is wrong with my setup. thanks for your help.

aastrong’s picture

sounds like you either have a caching issue when looking at your page - or maybe you have the wrong view on your page
Anyways, hope you figure it out - the patch is certainly working if you are seeing the settings change.
Cheers.

pinueve’s picture

Patch #107 works perfect, this is what I did, I zip downloaded 7.3 DEV version, unzip file, dowloaded #107 patch, place it in same dir of views-bootstrap module, open git bash in module dir, apply patch (git apply -v views_bootstrap-columns-per-device-2203111-107.patch), remove from server old module, upload new module (dev version with patch already applyied), clear caches, open your view, apply your custom settings (bootstrap-grid view), save changes, enjoy.

djake’s picture

Patch in #107 worked perfectly on dev.

kslagboom’s picture

Patch #107 worked for me.

Installed DEV version, Applied patch. Looks good.

zdean’s picture

tried to patch #107 on the dev using Terminal but got this error:

can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/plugins/grid/views_bootstrap_grid_plugin_style.inc b/plugins/grid/views_bootstrap_grid_plugin_style.inc
|index 9460652..f71613c 100644
|--- a/plugins/grid/views_bootstrap_grid_plugin_style.inc
|+++ b/plugins/grid/views_bootstrap_grid_plugin_style.inc
--------------------------
File to patch:

UPDATE: used "patch -p1" and seems to have worked.

rcodina’s picture

Status: Needs review » Reviewed & tested by the community

Patch #107 worked for me too! Please commit soon!

KarinG’s picture

confirming that patch 2203111-07 applies cleanly to 7.x-3.x-dev (and works great):

karins-macbook-pro:views_bootstrap sysadmin$ cat 2203111-107.patch |patch -p1
patching file plugins/grid/views_bootstrap_grid_plugin_style.inc
patching file plugins/thumbnail/views_bootstrap_thumbnail_plugin_style.inc
patching file templates/grid/theme.inc
patching file templates/grid/views-bootstrap-grid-plugin-style.tpl.php
patching file templates/thumbnail/theme.inc
patching file templates/thumbnail/views-bootstrap-thumbnail-plugin-style.tpl.php
patching file views_bootstrap.module

drush cc all

edit view ->et voilà!

tantadruj’s picture

Having some issues with applying the patch, using latest module version. Bellow link is an image of the problem.

http://i.imgur.com/NX5BTBr.png

What am i doing wrong?

ikeigenwijs’s picture

patch applied cleanly.

stevieb’s picture

Patch in #107 works

dadderley’s picture

thanks zdean
Had the same issue in Terminal when running the patch
This worked for the patch in 107:
patch -p1 < views_bootstrap-columns-per-device-2203111-107.patch

dadderley’s picture

The enhanced functionality is really nice.

thanks zdean
Had the same issue in Terminal when running the patch
This worked for the patch in 107:
patch -p1 < views_bootstrap-columns-per-device-2203111-107.patch

ikeigenwijs’s picture

updated credits before commiting

  • ikeigenwijs committed eee44d0 on 7.x-3.x
    Issue #2203111 by krystalcode, JurriaanRoelofs, joelstein, adam-delaney...
ikeigenwijs’s picture

Status: Reviewed & tested by the community » Closed (fixed)
adam-delaney’s picture

I have written an update hook that attempts to maintain backwards compatibility for grids before granular breakpoint control was committed. See: https://www.drupal.org/node/2807415#comment-11769694

jweirather’s picture

Just updating for any newcomers, the patch is committed to the dev version and appears to be working great.

Thanks to everybody who worked this out, provides great flexibility.

See also previous comment (128) about an update hook for backwards compatibility if you already have views built on this format.