sub cat is display when page is load

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
hey ..
i have same problem
nop version is 2.1 and i have  expecting the sub cat name   underneath in tree view when am load the page then directly display the sub category without click on cat name

Thank u....
12 years ago
@Ciwan
Hey..
i have same problem
nop version is 2.1 and i have  expecting the sub cat name   underneath in tree view when am load the page then directly display the sub category without click on cat name

Thank u....
12 years ago
Hello Seema

Are you familiar with JavaScript/jQuery ?

Using a line or two of jQuery code you can tell it to expand once the page loads.
12 years ago
Ciwan wrote:
Hello Seema

Are you familiar with JavaScript/jQuery ?

Using a line or two of jQuery code you can tell it to expand once the page loads.


No, that's not the case.  You can use browser developer tool to inspect the element, and you will not see ALL the categories.  Also, you can see the page submitting back to server when a category is clicked.

You will need to modify a controller and recompile.

Comment out these two lines.

\src\Presentation\Nop.Web\Controllers\CatalogController.cs

        private IList<CategoryNavigationModel> GetChildCategoryNavigationModel
...

                //for (int i = 0; i <= breadCrumb.Count - 1; i++)
                    //if (breadCrumb[i].Id == category.Id)
                        result.AddRange(GetChildCategoryNavigationModel(breadCrumb, category.Id, currentCategory, level +



It might be nice if this was a built in feature  (just need a system/config setting to test)
12 years ago
@new york....

Thank you so much...
i was facing same problem....
now its working perfectly..

Thank you....
12 years ago
Cool, thanks NY :)
12 years ago
Hello
When am do  category parent menu click then display its child sub category then dont display category parent menu
only display child sub category menu ..
and am using nopcommerce 2.1 version
Plz help me

Thank u
12 years ago
To display ONLY the children of a selected item, just call the GetChild...()  with the selected category's Id rather than 0 (root):


        public ActionResult CategoryNavigation(int currentCategoryId)
        {
            var currentCategory = _categoryService.GetCategoryById(currentCategoryId);
            var breadCrumb = currentCategory != null ? GetCategoryBreadCrumb(currentCategory) : new List<Category>();
            //!replaced! var model = GetChildCategoryNavigationModel(breadCrumb, 0, currentCategory, 0);
            int startCategoryId = breadCrumb.Count == 0 ? 0 : breadCrumb[breadCrumb.Count-1].Id;
            var model = GetChildCategoryNavigationModel(breadCrumb, startCategoryId, currentCategory, 0);            

            return PartialView(model);
        }

Note however, that when you select a leaf (category with no children), the entire Categories block will not appear - since there are NO children.  You'd have to modify more code (View or Controller) if you want some other appearance.
12 years ago
Thank u..... so much
12 years ago
@New York,

Its great to see its working listing only child categories. Can you please guide me, where and what I need to change to get neat and clean multi-level ul-li menu with child categories nested inside parent li item?

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