I wanted to show our categories in the top nav bar, so I adjusted SimpleCategoryList and made a new custom control to do this. Works great here:
http://dev.euroluxantiques.com/Default.aspx
However, on the product page and category page, the categories do not show up in the nav bar. Only the blog link shows up because it is hard coded in my custom SimpleCategoryList. Because I see the blog link there on these pages, I know I am referencing the custom control. Here are the 2 problem children:
http://dev.euroluxantiques.com/Furniture-C214.aspx
http://dev.euroluxantiques.com/New-Righ ... 24239.aspx
Is there something about these 2 pages that are not calling the categories in PageLoad, as it does on all other pages? Is there a workaround? The new layout editor really has my aggravated, and now this. Please help! Thanks!
Custom Header Issues in Product and Category Pages
-
- Commander (CMDR)
- Posts: 118
- Joined: Sat Dec 20, 2008 11:27 pm
Re: Custom Header Issues in Product and Category Pages
You need to understand the intended functionality of SimpleCategoryList control. The control was coded to list child categories of any given category or categories from root. For example on home page, contact or any other custom page it will list root categories since there is no category available in that context. On categories page it will list child categories of the category you are viewing. I think in case of product page it tries to find out the category in context which leads it to category product belongs too. The chances are product category doesn't have any sub category hence you endup with empty list.
There can be two ways to fix it. First if you always want to list only the root categories or specific categories then hard code the categoryid to load from. This can be done by locating following code lines
and then by updating it like
Where 1 is the category id which contains the sub categories to list.
Secondly if you want to keep the behaviour same means list categories child of the category in context in then you need to update the code like this
Hopefully this will help
There can be two ways to fix it. First if you always want to list only the root categories or specific categories then hard code the categoryid to load from. This can be done by locating following code lines
Code: Select all
if (_CategoryId < 0) _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
IList<Category> subCategories = GetSubcategories(_CategoryId);
Code: Select all
IList<Category> subCategories = GetSubcategories(1);
Secondly if you want to keep the behaviour same means list categories child of the category in context in then you need to update the code like this
Code: Select all
if (_CategoryId < 0) _CategoryId = AlwaysConvert.ToInt(request.QueryString["CategoryId"]);
IList<Category> subCategories = GetSubcategories(_CategoryId);
-
- Commander (CMDR)
- Posts: 118
- Joined: Sat Dec 20, 2008 11:27 pm
Re: Custom Header Issues in Product and Category Pages
Thanks Mazhar. I changed it to IList<Category> subCategories = GetSubcategories(0); and it loads my root categories perfectly on those 2 pages. Excellent!
Re: Custom Header Issues in Product and Category Pages
Mazhar,
is there an update to this code for R6? These changes do not work correctly in R6.
Looking to be sure that the SimpleCategoryList ConLib would show only those products which are contained in the currently-active Category.
I think that if this thread is updated to reflect R6, that this would work.
Can you please advise?
Thanks!
is there an update to this code for R6? These changes do not work correctly in R6.
Looking to be sure that the SimpleCategoryList ConLib would show only those products which are contained in the currently-active Category.
I think that if this thread is updated to reflect R6, that this would work.
Can you please advise?
Thanks!
Re: Custom Header Issues in Product and Category Pages
In order to list product you would need to update the following code
to look like
That should now start listing all products under active category.
Code: Select all
IList<Category> subCategories = GetSubcategories(_CategoryId);
CategoryList.DataSource = subCategories;
CategoryList.DataBind();
if (subCategories.Count == 0)
{
CategoryList.Visible = false;
NoSubcategoryMessage.Visible = true;
}
Code: Select all
if (_CategoryId < 0) _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
IList<CommerceBuilder.Products.Product> products = CommerceBuilder.Products.ProductDataSource.LoadForCategory(_CategoryId, false);
CategoryList.DataSource = products;
CategoryList.DataBind();
if (products.Count == 0)
{
CategoryList.Visible = false;
NoSubcategoryMessage.Visible = true;
}
Re: Custom Header Issues in Product and Category Pages
THANK YOU, Mazhar....
Much appreciated!
Much appreciated!