Post by Dutch Pride Code » Thu Feb 20, 2020 4:19 am

Already managed to get a two-column product view for small screens for featured.twig, bestseller.twig, special.twig and latest.twig but somehow I can't find a way to get a two-column product view for small screens for product searches and product categories...

Anyone knows which file, which line or which piece of code to edit for this?

Default store theme ( OC 3.0.3.2 )
Last edited by Dutch Pride Code on Thu Feb 20, 2020 7:02 am, edited 2 times in total.

User avatar
Active Member

Posts

Joined
Sun Jan 26, 2020 9:46 pm

Post by sw!tch » Thu Feb 20, 2020 4:32 am

Code: Select all

catalog/view/theme/default/template/product/category.twig
catalog/view/theme/default/template/product/search.twig

Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by Dutch Pride Code » Thu Feb 20, 2020 4:41 am

Thanks, so I'm looking at the right files here.
But what code do I have to adjust to allow a two column product view on small screens?

I tried editing all "col-xx-x" classes I could find, none of them change anything on my website :(
On all other parts of the website it's already fixed except for product search and category view...

User avatar
Active Member

Posts

Joined
Sun Jan 26, 2020 9:46 pm

Post by sw!tch » Thu Feb 20, 2020 4:48 am

You want to look at the product loop

Code: Select all

{% for product in products %}
and should see

Code: Select all

 <div class="product-layout product-list col-xs-12">
If using the default theme you have to adjust product-list class as well. Javascript adds additional classes depending on your grid mode.

If you look at catalog/view/javascript/common.js

and find

Code: Select all

$('#grid-view').click(function() {
You can see the classes are appended depending on the active grid mode, etc.

Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by by mona » Thu Feb 20, 2020 6:19 am

If I may, and despite no OC version posted nor extensions or themes ..

Surely the easiest way to do this would be to add a class to the product thumbs - and add css to the stylesheet

so you would have something like

Code: Select all

<div class="product-layout product-list col-xs-12 newclass”>

Code: Select all

@media screen and (max-width:768px) {
    .col-xs-12.newclass {
        width: 50%;
    }
}

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by sw!tch » Thu Feb 20, 2020 6:35 am

Don't think that will work since all product-list classes are replaced when the Javascript is executed.

Code: Select all

$('#content .product-list').attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');
You either have to remove product-list class and lose the gird toggle or edit common.js

Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by Dutch Pride Code » Thu Feb 20, 2020 7:01 am

sw!tch wrote:
Thu Feb 20, 2020 4:48 am
You want to look at the product loop

Code: Select all

{% for product in products %}
and should see

Code: Select all

 <div class="product-layout product-list col-xs-12">
If using the default theme you have to adjust product-list class as well. Javascript adds additional classes depending on your grid mode.

If you look at catalog/view/javascript/common.js

and find

Code: Select all

$('#grid-view').click(function() {
You can see the classes are appended depending on the active grid mode, etc.
This works, it was the classes in common.js that had to be changed too. Thanks a whole lot for your support ;D

User avatar
Active Member

Posts

Joined
Sun Jan 26, 2020 9:46 pm

Post by by mona » Thu Feb 20, 2020 8:20 am

sw!tch wrote:
Thu Feb 20, 2020 6:35 am
Don't think that will work since all product-list classes are replaced when the Javascript is executed.

Code: Select all

$('#content .product-list').attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');
You either have to remove product-list class and lose the gird toggle or edit common.js


yes you would have to write the full css path - thank you

Code: Select all

@media screen and (max-width:768px) {
        .product-layout.product-grid.col-lg-4.col-md-4.col-sm-6.col-xs-12,
	.product-layout.product-list.col-xs-12.newclass {
        width: 50%;
    }
}

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 12 guests