nopCommerce can display store items in list or grid (View as: List/Grid)
Is there a way to set the ListView as default? Preferable from within admin?
Markus
PS: I could make change to the code but don't like this because on updates sometimes you have to remember to fix everything you customized. So I try to keep it pure :_)
Unfortunately, this option was remove in 2.X version.
You will have to do it manually like this:
1. Go to admin area > configuration > settings > all settings 2. Find 'CatalogSettings.AllowProductViewModeChanging' setting ans set its value to 'false' 3. Open \src\Presentation\Nop.Web\Controllers\CatalogController.cs file 4. Find Category(int categoryId, CatalogPagingFilteringModel command) method 5. Replace
If you change the code the above way you will have to do it in more than one place. Additionally, if you change your mind and want the user to have the option to choose between list and grid it won't work anymore. Another alternative is to ensure when the model CatalogPagingFilteringModel is created that the default view mode is "list".
Therefore, change the following lines of code in CatalogPagingFilteringModel.cs
public CatalogPagingFilteringModel() { this.PriceRangeFilter = new PriceRangeFilterModel(); this.SpecificationFilter = new SpecificationFilterModel(); }
to
public CatalogPagingFilteringModel() { this.PriceRangeFilter = new PriceRangeFilterModel(); this.SpecificationFilter = new SpecificationFilterModel(); this.ViewMode = "list"; // make default view }
I was then able to (in Admin "Catalog Settings") disable "Allow view mode changing" and retain the list view as permanent (with option to re-enable if required).
I did this, because changing the view setting to list & disable changing was not permanent = every time I returned to Home page & reselect a product, it reverted to grid view [non src nop2.3]