Closed (fixed)
Project:
Views Bootstrap
Version:
8.x-3.2
Component:
Grid
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Sep 2020 at 02:06 UTC
Updated:
16 Dec 2020 at 00:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
shelaneDid you edit the configuration of the view after the update? There were structural changes that I couldn’t write an update hook for because it would have been making assumptions. You need to go in and edit how many columns are expected at the different Bootstrap breakpoint sizes (xs, sm, md, lg). Previously, they were breaking at 4 columns regardless if you wanted more.
Comment #3
zenimagine commentedI use 4 columns maximum. I re-registered my sight but there is no change. Since the update, everything is shifted :
https://www.s1biose.com/fr/article
Comment #5
shelaneI have added the ability to set the base number of columns. In your case, set it to 4. While I have committed the code, I'm not sure when I will be doing a release, so I have also attached a patch.
Comment #6
zenimagine commentedThanks, this corrects with 4 columns, but there is an old issue that came back. When I test the responsive, there is lag. This had been corrected a long time ago with "All" in the view settings.
Comment #7
zenimagine commentedComment #8
shelaneHmmm. Looking at the history of the file, the "all" was actually removed in the code in 2018. However, that wasn't released until the 3.2 release that I just did. So all of the column sizes should be divisible by 12. That is why the default per row had been set at 12. That would allow 12 in a row and then for them to break evenly. Here is a new patch with all (actually 999 as it was in 3.1). Please test. Test also the 12. I would love to know how/why it's not breaking evenly with 12.
Comment #9
zenimagine commentedI applied the patch on the stable version but it displays an error if I put 999
DivisionByZeroError : Modulo by zero dans template_preprocess_views_view_grid() (/home/ubuntu/www-example-com/web/core/modules/views/views.theme.inc ligne 713)
Comment #10
shelaneThat is a strange error there. Unless $options['columns'] is getting set to 0 somewhere in the views module, the math would never be a divide my zero. I wonder if there is another max allowed that I'm not seeing.
What happens when you set the base columns to 12?
I did that on my local tests with the patch and had things break as they should.
Comment #11
zenimagine commentedWhen I put 12 there is no error, but I have the same shift as 4
Comment #13
zenimagine commentedBootstrap lag problem has been around for a long time. This does not correct the problem. I don't know what changed :-(
Comment #14
mikee commentedHello, I think the Division By Zero Error in your patch can be resolved by changing:
'all' => 999
to:
999 => 'all'
Comment #15
mikee commentedHello zenimagine,
I was looking at https://www.s1biose.com/fr/article and believe if you set your 'Base number of columns' to 12 from the current 4 and update your 'views-bootstrap-grid.html.twig' file to include the lines below your columns will work without any gaps or lagging.
I hope that helps.
Comment #16
zenimagine commented@mikee I applied your templates but there are offsets when I reduce my window to display 3 columns.
Comment #17
mikee commentedHi ,
Sorry the other code was incorrect.
For your instance your require:
Please also see https://www.drupal.org/project/views_bootstrap/issues/3177126#comment-13...
Comment #18
zenimagine commented@mikee sorry, but can you post the full file? Thank you
Comment #19
mikee commented@zenimagine yes the full file is below.
Also in the Views UI under 'Settings' (Bootstrap Grid) the 'Base number of columns' should be set to either '12' or 'all' if available.
Comment #20
zenimagine commented@mikee Thank you I set the view to 12 and applied the templates but there is still some shift.
Comment #21
mikee commented@zenimagine, I've checked your page at https://www.s1biose.com/fr/article and for some reason the
aren't being output for some reason? I presume you've cleared the cache?
Comment #22
zenimagine commented@mikee Yes, I emptied the cache
Comment #24
shelaneThe dev version now has the “all” option and the alternate template (from #19) is available in the templates directory.
Comment #25
zenimagine commented@shelane I just put the dev version and empty the hide but I still have takeoffs in my grid.
Comment #26
mikee commentedHi @zenimagine,
Thanks for your screenshots. I had not realised but you have 2-columns for extra small devices. Sorry, I hadn't included this. Hence, you also need to add the following:
I hope this helps.
Comment #27
mikee commentedHi @zenimagine,
Just to clarify your screenshots show your site currently has the following number of Bootstrap columns:
Extra small devices: 2-columns
Small devices: 2-columns
Medium devices: 3-columns
Large devices: 4-columns
However, additionally there is some extra CSS (nonstandard for Bootstrap 3) for devices equal or smaller than 480px to make just 1-column. The CSS code is similar to:
I mention this because at first glance your site https://www.s1biose.com/fr/article appears to have 1-column for extra small devices.
Comment #28
shelaneI am concerned about what is happening here. If this template is being specified for this use case only, then it won't be good to include with the module. I don't know why the rows are not breaking properly. Looking at the site, it doesn't appear that any other CSS is causing the issue. I also don't know why it "worked" before when the changes have been around adding custom row and col classes to be added. There was one commit in history that removed the ability to set the default base columns and the default was set at 4. However, that happened between the 3.1 and 3.2 release and the functionality was returned and the default set to 12, which is the Bootstrap base.
Comment #29
shelaneHere is a basic alternate template:
Comment #30
zenimagine commented@shelane I applied your templates, it looks better, but on 3 columns there is a huge offset.
Comment #31
shelaneHmmm. Alright then. I’m going to take a different approach and play around with your code output manually and see if I can come up with the missing piece to this puzzle.
Comment #32
mikee commented@shelane,
Many thanks - I replaced my template with yours above #29 and it's currently working very well. In the past I thought I'd encountered problems with lags and hence I'd come up with my own version.
@zenimagine, I think you may need to set the 'Base number of columns' to 12 for your page to work. At the moment, with the 'Base number of columns' set to '4' the loop.index is going from 1-4 within the first, second and third row which means the 'divisible by' logic doesn't get chance to work correctly.
For example, after the sixth loop the loop.index is back to 2 (not 6) so the 'clearfix-md' isn't being placed (as 2 isn't divisible by 3) but gets incorrectly placed on the next cycle when the index is '3' (7th loop).
Comment #34
zenimagine commented@mikee Thank you, yes now it works ;-)
Comment #35
shelaneThat is fantastic. It's set as the alternate template in the new release.
Comment #36
zenimagine commentedSorry to reopen this problem. Bad news, I'm on the latest stable version, I deleted the custom templates and I targeted the cache.
There are again holes in the grid.
Comment #37
zenimagine commentedComment #38
shelaneSo you updated to to 8.x-3.4. Are you using that alternate template in your theme? Those changes are not in the default template, but instructions for using the alternate template are in that template file.
Comment #39
zenimagine commented@shelane Yes I am on the latest version and no I thought the templates were part of the last version, so I deleted the file from my theme.
Comment #40
zenimagine commented@shelane I do not understand anything. Should use the template? If yes, why ? Or you have to wait for an update.
Comment #41
shelaneIf you need the "fix" immediate, copy the alternate template to your theme and rename it as the instructions say. I will not be able to make a code release for a while.
Comment #42
zenimagine commentedok thank you
Comment #44
shelaneSince the alternate template was deemed good for all purposes, that is now the main template and the "alternate" has been removed.