How to make category list expanded by default

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
Hi all,
i have categories and sub categories.i need to enable first category is expanded by default.or are there any setting to make all make expanded ?

Thanks
Nish
http://www.nishshanka.net Geek inside
14 years ago
It's not implemented in default release. You need to modify NopCommerceStore\Modules\CategoryNavigation.ascx.cs
14 years ago
I have been trying for a long time to implement this, but am not getting anywhere.

I am quite new to c# and not so comfortable yet with nopCommerce.

Is there anyone who can offer guidance or code to this effect?

I have noticed that the current method gets products by parent category Id of 0 which means the main categories.

I have been trying to add a method with the same signature, but no parameters. However, I am not familiar enough with the backend architecture to succeed.  I am getting errors: copied below:


System.Configuration.ConfigurationErrorsException was unhandled by user code
  Message="Method 'GetAllCategories' in type 'NopSolutions.NopCommerce.DataAccess.Categories.SQLCategoryProvider' from assembly 'Nop.DataAccess.SqlServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
  Source="System.Web"
  BareMessage="Method 'GetAllCategories' in type 'NopSolutions.NopCommerce.DataAccess.Categories.SQLCategoryProvider' from assembly 'Nop.DataAccess.SqlServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation."

  
I have added GetAllCategories() to CategoryManager.cs and DBCategoryProvider.cs






Any help is highly appreciated. Thanks in advance!!
14 years ago
You should add the same method to SqlCategoryProvider that inherits DBCategoryProvider
7 years ago
Is there any way to display the category and all of its' subcategories expended in the right column in Version 3.40?
7 years ago
The category list can be expanded by updating the CategoryNavigation.cshtml file.

replace


if (category.Id == Model.CurrentCategoryId ||
                category.SubCategories.Count(BreadCrumbContainsCurrentCategoryId) > 0)
            {
                if (category.SubCategories.Count > 0)
                {
            <ul class="sublist">
                @foreach (var subCategory in category.SubCategories)
                {
                    @RenderCategoryLine(subCategory)
                }
            </ul>
                }
            }


with


<!-- Always expand all categories -->
if (true)
            {
                if (category.SubCategories.Count > 0)
                {
            <ul class="sublist">
                @foreach (var subCategory in category.SubCategories)
                {
                    @RenderCategoryLine(subCategory)
                }
            </ul>
                }
            }


Or if you want to selectively expand categories something like this ..


<!-- Always expand the "Products" category and the current category -->
if (category.Id == Model.CurrentCategoryId || category.Name == "Products" ||
    category.SubCategories.Count(BreadCrumbContainsCurrentCategoryId) > 0)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.