CategoryDropDownList ignores the level setting

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
User avatar
efficiondave
Commander (CMDR)
Commander (CMDR)
Posts: 151
Joined: Tue Dec 02, 2008 10:20 am
Location: St. Louis Missouri
Contact:

CategoryDropDownList ignores the level setting

Post by efficiondave » Wed Feb 04, 2015 1:46 pm

The Conlib/CategoryDropDownList.ascx has a Levels setting that should dictate the number of levels displayed but it doesn't work.

To fix it, you need to add an if statement within the GetCategoryListItemsRecursive function:

Code: Select all

        private ListItem[] GetCategoryListItemsRecursive(int categoryId, int level)
        {
            List<ListItem> subcatList = new List<ListItem>();
            IList<Category> subcategories = CategoryDataSource.LoadForParent(categoryId, true);
            foreach (Category subcat in subcategories)
            {
                string prefix = new string(' ', level).Replace(" ", Server.HtmlDecode(_Prefix));
                subcatList.Add(new ListItem(prefix + subcat.Name, subcat.Id.ToString()));
		   if (level < Levels) //added this along with the brackets surrounding the following 2 lines
		   {
	                ListItem[] subcatItems = GetCategoryListItemsRecursive(subcat.Id, level + 1);
	                if (subcatItems != null) subcatList.AddRange(subcatItems);
		   }
            }
            if (subcatList.Count == 0) return null;
            return subcatList.ToArray();
        }

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: CategoryDropDownList ignores the level setting

Post by sfeher » Thu Jun 29, 2017 3:58 am

This still doesn't work on Gold R12 SR1.

Does this edit work for you still, Dave?

User avatar
efficiondave
Commander (CMDR)
Commander (CMDR)
Posts: 151
Joined: Tue Dec 02, 2008 10:20 am
Location: St. Louis Missouri
Contact:

Re: CategoryDropDownList ignores the level setting

Post by efficiondave » Thu Jun 29, 2017 8:15 am

Sorry, haven't upgraded to R12 yet so I don't know.

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: CategoryDropDownList ignores the level setting

Post by sfeher » Thu Jun 29, 2017 8:27 am

Katie / Mazhar / Able:

I've not seen any other posts on this topic for R12 --- but its performing just the same as David's experience in this initial post on the thread.
I've attempted his fix, but Gold R12 SR1 doesn't improve on this.

Any ideas??

Thanks in advance!
Steve

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: CategoryDropDownList ignores the level setting

Post by nadeem » Wed Jul 05, 2017 3:30 am

You need to modify the code provided by David a little to make it work correctly.

Change the following line of code

Code: Select all

if (level < Levels)
To

Code: Select all

if (Levels == 0 || level <= Levels)

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: CategoryDropDownList ignores the level setting

Post by sfeher » Fri Jul 14, 2017 6:10 am

Nadeem ---
I'm sorry that this has taken me so long to respond.
For starters, thank you for your willingness to help. I'm always appreciative.

The answer you provided doesn't seem to have any effect on the Dropdown menu. The behavior has not changed.
I've tried to be sure that the cache was clear, etc. Still no avail.

Any other thoughts?

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: CategoryDropDownList ignores the level setting

Post by nadeem » Mon Jul 17, 2017 10:27 pm

Can you please describe the scenario how your testing? I have this tested myself by applying the CategoryDropDownList control to leftsidebar and then changing the levels value in the code (int _Levels = somevalue;). This is all working fine for me.

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: CategoryDropDownList ignores the level setting

Post by sfeher » Tue Jul 18, 2017 7:38 am

Nadeem -

I've got the conlib installed on a page.

Code: Select all

<h1>Search for Parts&nbsp;</h1>
<div>Select a model from the list below and begin your search through our extensive inventory. &nbsp;</div>
[[ConLib:CategoryDropDownList HomeText="Back to Top" Prefix=".." Levels="0" AutoPostBack="True" GoButtonText="" CacheDuration="0"]]
I realize that the present setting of having Levels="0" should display "all", but even when changed to 1 or another digit, there is no change in the Levels being displayed.
Really not sure why being placed in the main page content well doesn't work, when it does work in the leftsidebar.

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: CategoryDropDownList ignores the level setting

Post by nadeem » Tue Jul 18, 2017 8:14 pm

I used the same code you provided on the home page content and it does worked correctly. I am not sure why it isn't working in your case.

One more thing, are you using WSP version or WAP? If you are using WAP then any change to code require recompile of the Ablecommerce project using some editor like Visual Studio.

Also is your CategoryDropDownList control customized or the stock AbleCommerce control? If you can provide me the control files I can look into code to see if anything isn't correct.

You can do a test by creating a simple category structure. For example, create a category structure like Sample -> level 1 -> level 2 -> level 3 and then try setting the level parameter value.

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: CategoryDropDownList ignores the level setting

Post by sfeher » Wed Jul 19, 2017 12:43 am

Nadeem --
Using the WSP version -- Gold R12 SR1. Latest Version.
Attempted to use the same CategoryDropdownList control on a second site which has zero customizations. That also failed.
I'll forward you my control files and you can review, but I really don't know why this has failed.

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: CategoryDropDownList ignores the level setting

Post by Katie » Wed Jul 19, 2017 2:22 am

Hello Steve,

We can help troubleshoot the issue and review your files, but that normally falls under paid support. If we did find a bug, then of course you will be refunded.

Thanks
Katie
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

Post Reply