Category Sidebar - How to force category list to show (open) on home page?

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

I tried searching for this issue but couldn't find the right wording perhaps. My apologies if this question has already been answered.

I'm working with v4.2 - recently upgraded from v1.6. My client has about 33 categories I think, and to keep the header menu under control, I created a new category called "Categories", and then made it the parent for all of the others. Now I have just the one "Categories" dropdown in the header menu, which is great!

The problem, however, is that now on the home page, the left sidebar category widget is closed - with just the word "Categories" showing. I must click on it to see the whole list of categories (which actually takes me to the categories page). Is there a way to force this sidebar to be open on the home page as well... to show all the categories in the list?

Thank you so much for your time!
4 years ago
Are you using any custom theme from partners?
NopCommerce's default theme does not have left sidebar on homepage. https://demo.nopcommerce.com/
And in category page. The child categories of the category will automatically expand once you visit the category listing page. Check the https://demo.nopcommerce.com/cell-phones  Cell phone subcategory.  All of its siblings are expanded and visible on the left panel.
4 years ago
Yes, I am using a customized version of the noble theme from nopAccelerate. It comes with a Categories sidebar, and it works great. With it, the categories are closed by default, until clicked on.

After parenting all categories (all 33) to a single category (so that the header menu worked the way I wanted), the sidebar "Categories" item is closed on the home page, but open on all other pages.

I was just wondering if anyone knew of a way to force the sidebar widget to be open on the home page as well.
4 years ago
WebMagi wrote:
Yes, I am using a customized version of the noble theme from nopAccelerate. It comes with a Categories sidebar, and it works great. With it, the categories are closed by default, until clicked on.

After parenting all categories (all 33) to a single category (so that the header menu worked the way I wanted), the sidebar "Categories" item is closed on the home page, but open on all other pages.

I was just wondering if anyone knew of a way to force the sidebar widget to be open on the home page as well.


Hi WebMagi,

if you could give a working link to your store we could probably give you a suggestion for this.

Looking forward to your answer!

Best Regards,
Valentin.
4 years ago
WebMagi wrote:
I was just wondering if anyone knew of a way to force the sidebar widget to be open on the home page as well.

Without working link, it`s hard to tell with 100% sure.
If you open demo link of category view (with sidebar), you may check that toggle effect of the category is related with class - inactive/active. Maybe your theme just need to apply script/hard coded class to solve issue?

Regards,
Tom
4 years ago
There is probably a more elegant way to do this, but a quick and dirty edit is:

Nop.Web/Views/Home/Index.cshtml  (for stock DefaultClean theme, sounds like your theme already does this)
Layout = "_ColumnsTwo";


Nop.Web/Views/Shared/_CategoryLine.Navigation.cshtml (assuming your theme uses this)

        if (Model.Category.Id == Model.CurrentCategoryId ||
            Model.Category.SubCategories.Count(BreadCrumbContainsCurrentCategoryId) > 0 ||
            (Model.Category.Id == 39 && Model.CurrentCategoryId == 0))
        {
            if (Model.Category.SubCategories.Count > 0)
            {
                <ul class="sublist">
                    @foreach (var subCategory in Model.Category.SubCategories)
                    {
                        var categoryLineModel = new CategoryNavigationModel.CategoryLineModel
                        {
                            CurrentCategoryId = Model.CurrentCategoryId,
                            Category = subCategory
                        };
                        @await Html.PartialAsync("_CategoryLine.Navigation", categoryLineModel)
                    }
                </ul>
            }
        }


where Model.Category.Id is your "Categories" ID.

CurrentCategoryId  is 0 on the homepage so this will force the recursion when it hits your "Categories" category.
4 years ago
af1racing wrote:
There is probably a more elegant way to do this, but a quick and dirty edit is...


Worked beautifully! Thank you! I really appreciate your help with this!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.