Need dropdown listbox using categoryID, parentID, level

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
lab_n_chemicals
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 33
Joined: Mon Mar 10, 2008 12:18 am
Location: us
Contact:

Need dropdown listbox using categoryID, parentID, level

Post by lab_n_chemicals » Thu Apr 17, 2008 10:53 am

Can anyone modify categorydropdownlist to include categoryID, parentID, level as query parameters so I can set up my major categories as separate lists?

Thx in advance
Lab supplies, consumables & chemicals
http://www.espchemicals.com

User avatar
m_plugables
Commander (CMDR)
Commander (CMDR)
Posts: 149
Joined: Tue Mar 11, 2008 12:44 am
Contact:

Re: Need dropdown listbox using categoryID, parentID, level

Post by m_plugables » Fri Apr 18, 2008 4:52 am

You need to modify the ConLib/CategoryDropDownList.ascx.cs file. Locate the following line of code in the file

Code: Select all

subcatList.Add(new ListItem(prefix + subcat.Name, subcat.CategoryId.ToString()));
and replace with the following line of code

Code: Select all

subcatList.Add(new ListItem(prefix + subcat.Name, subcat.CategoryId.ToString()+","+subcat.ParentId.ToString()+","+level.ToString()));
Now made the CategoryRedir() function look like

Code: Select all

private void CategoryRedir()
    {
        string[] queryParameters = CategoryList.SelectedValue.Split(',');
        int categoryId = AlwaysConvert.ToInt(queryParameters[0]);
        int parentId = AlwaysConvert.ToInt(queryParameters[1]);
        int level = AlwaysConvert.ToInt(queryParameters[2]);

        if (categoryId == 0) Response.Redirect(NavigationHelper.GetHomeUrl());
        Category category = CategoryDataSource.Load(categoryId);
        if (category != null)
        {
                  Response.Redirect(category.NavigateUrl);
        }
    }
Now CategoryId, ParenId and Level all information is available in the above function for usage.
Image
Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com

lab_n_chemicals
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 33
Joined: Mon Mar 10, 2008 12:18 am
Location: us
Contact:

Re: Need dropdown listbox using categoryID, parentID, level

Post by lab_n_chemicals » Fri Apr 18, 2008 2:18 pm

Thx very much. Appreciate you time.
Lab supplies, consumables & chemicals
http://www.espchemicals.com

deadlybuda
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 22
Joined: Wed Jun 24, 2009 3:39 pm

Re: Need dropdown listbox using categoryID, parentID, level

Post by deadlybuda » Wed Jul 15, 2009 5:10 pm

Hi, could I get some further clarification on this code?
In my situation, I have 3 major cateogories: Brands, Lighting, and Collections. I need a separate drop down list for each category.

How would I use this code to specify, for example, just "Collections"? I assume I have to plug in the CategoryID somewhere, but I can't figure out where to do it.
Any help would be greatly appreciated.


Khaliq
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 26
Joined: Tue Dec 16, 2008 2:00 am

Re: Need dropdown listbox using categoryID, parentID, level

Post by Khaliq » Thu Jul 16, 2009 5:31 am

deadlybuda wrote:Hi, could I get some further clarification on this code?
In my situation, I have 3 major cateogories: Brands, Lighting, and Collections. I need a separate drop down list for each category.

How would I use this code to specify, for example, just "Collections"? I assume I have to plug in the CategoryID somewhere, but I can't figure out where to do it.
Any help would be greatly appreciated.
Yes you can use the category Id in the control to get items only from that category. You can probably define a parameter CategoryId for the control and the place where you use it in the scriptlet you can set the category id.

User avatar
mmackrell
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 50
Joined: Sun Mar 28, 2010 7:41 pm
Location: Zelienople, PA
Contact:

Re: Need dropdown listbox using categoryID, parentID, level

Post by mmackrell » Mon May 10, 2010 7:27 pm

This is a great post, but I have a question. I assume that I would set the parent category id in the scriplet. This is what I have in the scriptlet and it appears to not be working:

[[ConLib:Custom/SimpleCategoryList ]]
[[ConLib:Custom/CategoryDropDownList Levels="1" Prefix="." AutPostBack="true" CacheDuration="0" parentId="5373"]]

I have also tried changing the category id in the aspx like you referenced in viewtopic.php?f=44&t=11652 and that does not work either.

I am not a developer, so direction would be appreciated.

Oh, I would also like to know where I would go to set the width for this dropdown list. I put have played around with putting this in it's own div with a set width, but that doesn;t seem to be cutting it. Is there a setting in the aspx.cs file that would control the wrap of the list?

User avatar
mmackrell
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 50
Joined: Sun Mar 28, 2010 7:41 pm
Location: Zelienople, PA
Contact:

Re: Need dropdown listbox using categoryID, parentID, level

Post by mmackrell » Mon May 10, 2010 8:08 pm

I figured out where to set the width for the drop down list - yay...

Again, any help with setting the parent category id would be greatly appreciated.

Regards,
Margie

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Need dropdown listbox using categoryID, parentID, level

Post by mazhar » Tue May 11, 2010 6:13 am

mmackrell wrote:I figured out where to set the width for the drop down list - yay...

Again, any help with setting the parent category id would be greatly appreciated.

Regards,
Margie
This control doesn't support any ParentId parameter at scriptlet level. The discussion being done in few posts above makes use of custom parent id parameter passed through query string. If you want to support ParentId in this control to list child categories only that can be used via scriptlet then you need to put something like in this control.

Code: Select all

private int _ParentId;
public int ParentId
{
get{return _ParentId;}
set{_ParentId=value;}
}
finally locate following code

Code: Select all

categoryList = GetCategoryListItemsRecursive(0, startLevel);
and change it like

Code: Select all

categoryList = GetCategoryListItemsRecursive(ParentId, startLevel);
Now save it and give a try via passing parent id through scriptlet.

User avatar
mmackrell
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 50
Joined: Sun Mar 28, 2010 7:41 pm
Location: Zelienople, PA
Contact:

Re: Need dropdown listbox using categoryID, parentID, level

Post by mmackrell » Wed May 12, 2010 5:10 pm

This works GREAT!!! Thanks for all your help Mazhar :)

Margie

User avatar
mmackrell
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 50
Joined: Sun Mar 28, 2010 7:41 pm
Location: Zelienople, PA
Contact:

Re: Need dropdown listbox using categoryID, parentID, level

Post by mmackrell » Sat Sep 04, 2010 3:40 pm

Mazhar,

Another quick question pertaining to this. I only want one level appearing from my parent category, so I enter

Code: Select all

[[ConLib:Custom/CategoryDropDownList Levels="1" AutPostBack="true" HomeText=" Hospitals by Department" CacheDuration="0" Prefix="" ParentId="5525"]]
However, I am still seeing more the one level down, how do I correct this? I have tried setting the levels to 0 and I still see multiple levels down.

Thanks in advance.
Margie

Post Reply