Page 1 of 1
SimpleCategoryList question
Posted: Sun Sep 23, 2007 9:37 am
by tomascarpio5
Hi Guys,
I'm new to ASP.NET and do have question about this code on AC 7. This file is the one use to show the list of categoies available in the store that can be found in the left side bar. But we do need to put it on the header area. So what I did was to copy the user control call to the header and it did worked out in the Home page area but once I select a category, the list disappears. What do i need to do on order to show the list all the time?
Please let me know if it do make sense.
Thanks!
Tomas
Posted: Mon Sep 24, 2007 10:38 am
by Logan Rhodehamel
The "simple list" control doesn't have the ability you ask. But with a small update, I think it will. The content of the file webparts/SimpleCategoryList.ascx has to be updated to this:
Code: Select all
<%@ Control Language="C#" ClassName="SimpleCategoryList" EnableViewState="false" %>
<script runat="server">
private string _CssClass;
private string _HeaderCssClass;
private string _HeaderText;
private string _ContentCssClass;
private int _CategoryId = -1;
public int CategoryId
{
get { return _CategoryId; }
set { _CategoryId = value; }
}
[Personalizable(), WebBrowsable()]
public string CssClass
{
get { return _CssClass; }
set { _CssClass = value; }
}
[Personalizable(), WebBrowsable()]
public string HeaderCssClass
{
get { return _HeaderCssClass; }
set { _HeaderCssClass = value; }
}
[Personalizable(), WebBrowsable()]
public string HeaderText
{
get { return _HeaderText; }
set { _HeaderText = value; }
}
[Personalizable(), WebBrowsable()]
public string ContentCssClass
{
get { return _ContentCssClass; }
set { _ContentCssClass = value; }
}
protected void Page_PreRender(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(CssClass)) MainPanel.CssClass = CssClass;
if (!string.IsNullOrEmpty(HeaderCssClass)) HeaderPanel.CssClass = HeaderCssClass;
if (!string.IsNullOrEmpty(HeaderText)) HeaderTextLabel.Text = HeaderText;
if (!string.IsNullOrEmpty(ContentCssClass)) ContentPanel.CssClass = ContentCssClass;
if (_CategoryId < 0) _CategoryId = PageHelper.GetCategoryId();
CategoryList.DataSource = CategoryDataSource.LoadForParent(_CategoryId, true);
CategoryList.DataBind();
}
</script>
<asp:Panel ID="MainPanel" runat="server" CssClass="section">
<asp:Panel ID="HeaderPanel" runat="server" CssClass="header">
<h2 class="header"><asp:Localize ID="HeaderTextLabel" runat="server" Text="Categories"></asp:Localize></h2>
</asp:Panel>
<asp:Panel ID="ContentPanel" runat="server" CssClass="content">
<asp:Repeater ID="CategoryList" runat="server">
<HeaderTemplate>
<ul class="category">
</HeaderTemplate>
<ItemTemplate>
<li><asp:HyperLink ID="CategoryLink" runat="server" Text='<%#Eval("Name")%>' NavigateUrl='<%#Eval("NavigateUrl")%>'></asp:HyperLink></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
</asp:Panel>
After making this update, you can put this into your header:
Code: Select all
[[Custom/SimpleCategoryList.ascx CategoryId="0"]]
That will make the category list always show your top level categories.
Posted: Mon Sep 24, 2007 11:27 am
by tomascarpio5
Awesome! yes it did work... Thanks a lot for your quick reply

Having trouble with these instructions in Able Commerce 7
Posted: Thu Dec 20, 2007 1:15 pm
by chazen
The post mentions modifying a file named webparts/SimpleCategoryList.ascx
I do not see a webparts subdirectory to go into but in searching for a file named SimpleCategoryList.ascx I do see one under a subdirectory named "conlib" I made a backup copy of SimpleCategoryList.ascx by renaming this file with a .bak extension. I downloaded the file to my PC and replaced the text in the file with the text shown in this article and uploaded it back to the server.
I also added the text mentioned to the header, but I was not sure exactly where to add it in the header. I tried many different places in the header, but cannot get it to work. Can you post and example of the header and where you post the code within the header? By header do you mean to edit the part called "standard header" in Able Commerce 7? I also tried putting the SimpleCategoryList.ascx file in the custom subdirectory under "conlib", but still cannot get the left sidebar to stay. Since the subdirectory is called conlib shouldn't the code for the header be changed to something like:
[[conlib/SimpleCategoryList.ascx CategoryId="0"]]
Mystore is setup like this in a subdirectory named store:
http://www.mywebsite.com/store
Never mind I figured it out
Posted: Tue Dec 25, 2007 12:58 am
by chazen
The standard sidebar1 needed to be moddified as follows:
[[conlib:SimpleCategoryList CategoryId="0"]]
The default looked like this:
[[conlib:SimpleCategoryList]]
I used the code posted above (SimpleCategoryList.ascx) except for the one line it mentioned to add to the header. Active layout is set to 3 column and the standard sidebar1 looks as follows:
[[conlib:SimpleCategoryList CategoryId="0"]]