Virtuemart products page - list view as default

souacz
54 Posts
souacz posted this 11 January 2022

Hi,

How to set a list view as default in category page? I'd like to remove view mode switcher but the grid view is set as default and it is not possible to force list view...

Hi, How to set a list view as default in category page? I'd like to remove view mode switcher but the grid view is set as default and it is not possible to force list view...
Vote to pay developers attention to this features or issue.
2 Comments
Order By: Standard | Newest
athenaios83
2 Posts
athenaios83 posted this 11 February 2022

I'm interested too.
I suppose we may edit some jquery in the template to invert the logic and then hide the switcher through css, but I'd rather not edit the generated template files manually.

I'm interested too. I suppose we may edit some jquery in the template to invert the logic and then hide the switcher through css, but I'd rather not edit the generated template files manually.
athenaios83
2 Posts
athenaios83 posted this 11 February 2022

Here's what we did, in case it can be helpful to someone else:

we applied a simple workaround that didn't touch the template's file: we just added a few simple lines of javascript to simulate a click on the selector, and we hid the selector with CSS

<script>  document.addEventListener('DOMContentLoaded', function(){  var element = document.querySelector("[data-layout-name='bd-griditemlist']");element.click(); });</script>

This simple script gets the list style selector and clicks on it as soon as the page is loaded, resulting in the desidered view.
Maybe it's not a clean solution but it works and it doesn't require to alter the template's files.

Here's what we did, in case it can be helpful to someone else: we applied a simple workaround that didn't touch the template's file: we just added a few simple lines of javascript to simulate a click on the selector, and we hid the selector with CSS <script> document.addEventListener('DOMContentLoaded', function(){ var element = document.querySelector("[data-layout-name='bd-griditemlist']");element.click(); });</script> This simple script gets the list style selector and clicks on it as soon as the page is loaded, resulting in the desidered view. Maybe it's not a clean solution but it works and it doesn't require to alter the template's files.

Last edited 11 February 2022 by athenaios83

You must log in or register to leave comments