For specific url referrers to the ac7 site we want to show one category and its products and for anyone else a different category and is products. We changed the SimpleCategoryList.cs code thus:
if (HttpContext.Current.Request.UrlReferrer.ToString().Contains("http://localhost/testexchange") || HttpContext.Current.Request.UrlReferrer.ToString().Contains("http://www.exchangeonlinemall.com/defau ... =aafes.com"))
{
referrerCategoryId = 7;
}
else
referrerCategoryId = 8;
but this does not load any categories at all.
If we let it default to a value of zero then both categories show and we do not want that.
What am I doing wrong? Any help is appreciated. Once we have this working we can do the same for featured products, top sellers, etc. I hope!
how to show/hide categories
Re: how to show/hide categories
Loading the categories for an id =0 means load the root categories. In your case i think that you have two root categories. What you are currently doing will load the children of the the specified category. For example when you load for id=7 then its children will be loaded. If you want to show one of the root category and hide the other then you can try by first loading for root categories by providing an id=0 and then removing the category that you don't want to show from the loaded data.
For example if we look into the SimpleCategoryList control then we found the following statements loading the data
You can customize these statements to meet your needs as below
For example if we look into the SimpleCategoryList control then we found the following statements loading the data
Code: Select all
CategoryList.DataSource = CategoryDataSource.LoadForParent(_CategoryId, true);
CategoryList.DataBind();
Code: Select all
CategoryCollection categories = CategoryDataSource.LoadForParent(_CategoryId, true);
Category hiddenCat = null;
foreach (Category c in categories)
if (c.CategoryId == 1)
{
hiddenCat = c;
break;
}
if (hiddenCat != null)
categories.Remove(hiddenCat);
CategoryList.DataSource = categories;
CategoryList.DataBind();
Re: how to show/hide categories
Thanks, that is great! Just what we needed.