sub grid category

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi,

I cannot seem to find where I need to remove the sub category in grid form that shows on the subcategory pages with the sub category titles in version 4.20

Regards
4 years ago
Do you mean you only want lines and not a grid ?

This is in the category template

nopCommerce42\Presentation\Nop.Web\Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml
4 years ago
Yidna wrote:
Do you mean you only want lines and not a grid ?

This is in the category template

nopCommerce42\Presentation\Nop.Web\Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml


Hi,

I will have a look at that, here is a photo of what I am on about.


https://www.flickr.com/photos/185321986@N02/shares/8639sK


Regards
4 years ago
Hi garrie007,

if you want to remove the sub-category grid the easiest way is to hide it with some CSS like so:

.category-page .sub-category-grid {
     display: none;
}


However, the best and safest way would be to comment them out from the above-mentioned view file. But if you are using any theme it would be in the following location:

~ Presentation\Nop.Web\Themes\{ThemeName}\Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml

And the part you want to comment-out is the sub-category-grid wrapper with everything in it:

@*<div class="category-grid sub-category-grid">
...
</div>*@



Best Regards,
Valentin.
4 years ago
If you are working with source code then it will be good to comment out subcategory generating code from the source code/code behind. It will also increase the performance a little. As you do not need it at the front end then from the code behind no need to manipulate/generate the subcategory. To comment out the code you need to go to the Presentation==>Nop.Web==>Factories==>PrepareCategoryModel method and comment out the bellow code

            
var subCategoriesCacheKey = string.Format(NopModelCacheDefaults.CategorySubcategoriesKey,
                category.Id,
                pictureSize,
                string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()),
                _storeContext.CurrentStore.Id,
                _workContext.WorkingLanguage.Id,
                _webHelper.IsCurrentConnectionSecured());

            model.SubCategories = _cacheManager.Get(subCategoriesCacheKey, () =>
                _categoryService.GetAllCategoriesByParentCategoryId(category.Id)
                .Select(x =>
                {
                    var subCatModel = new CategoryModel.SubCategoryModel
                    {
                        Id = x.Id,
                        Name = _localizationService.GetLocalized(x, y => y.Name),
                        SeName = _urlRecordService.GetSeName(x),
                        Description = _localizationService.GetLocalized(x, y => y.Description)
                    };

                    //prepare picture model
                    var categoryPictureCacheKey = string.Format(NopModelCacheDefaults.CategoryPictureModelKey, x.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id);
                    subCatModel.PictureModel = _cacheManager.Get(categoryPictureCacheKey, () =>
                    {
                        var picture = _pictureService.GetPictureById(x.PictureId);
                        var pictureModel = new PictureModel
                        {
                            FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
                            ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize),
                            Title = string.Format(_localizationService.GetResource("Media.Category.ImageLinkTitleFormat"), subCatModel.Name),
                            AlternateText = string.Format(_localizationService.GetResource("Media.Category.ImageAlternateTextFormat"), subCatModel.Name)
                        };
                        return pictureModel;
                    });

                    return subCatModel;
                }).ToList());
4 years ago
Nop-Templates.com wrote:
Hi garrie007,

if you want to remove the sub-category grid the easiest way is to hide it with some CSS like so:

.category-page .sub-category-grid {
     display: none;
}


However, the best and safest way would be to comment them out from the above-mentioned view file. But if you are using any theme it would be in the following location:

~ Presentation\Nop.Web\Themes\{ThemeName}\Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml

And the part you want to comment-out is the sub-category-grid wrapper with everything in it:

@*<div class="category-grid sub-category-grid">
...
</div>*@



Best Regards,
Valentin.


Thank you very much.

regards
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.