Left Sidebar in AC Gold (scriptlet in old version)

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
surf
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Fri Dec 05, 2008 10:33 am

Left Sidebar in AC Gold (scriptlet in old version)

Post by surf » Mon Oct 01, 2012 6:43 pm

Can someone please explain how to create a custom left sidebar in AC Gold. In the prevsious version it was easy to create a side bar with the scriptlets. Do you have to hard code custom sidebars in Gold?? In the previous version you could create headers, footers, sidebars, etc.. with scriptlets.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Left Sidebar in AC Gold (scriptlet in old version)

Post by jmestep » Tue Oct 02, 2012 6:56 am

I haven't tried it yet, but Able has been adding capabilities and it looks like you need to create one implementing ISidebar.
viewtopic.php?f=65&t=16733
Available controls gets populated by examining the controls in the ConLib folder (and it's subdirectories). It looks for controls that implement the CommerceBuilder.UI.ISidebarControl interface. If you create new controls, you can do the same and your control will be included into the list. (In our next update, header and footer controls will additionally be supported in this fashion with IHeaderControl and IFooterControl interfaces.)
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Left Sidebar in AC Gold (scriptlet in old version)

Post by david-ebt » Tue Oct 02, 2012 9:20 am

It's still pretty simple to make customer sidebar controls or headers and footers.

For sidebars, you need to include the ISidebarControl in the code behind like this:

Code: Select all

public partial class SimpleCategoryList : System.Web.UI.UserControl, ISidebarControl
for headers you need to include IHeaderControl:

Code: Select all

public partial class StoreHeader : System.Web.UI.UserControl, IHeaderControl
and for footers you need to include IFooterControl:

Code: Select all

public partial class StoreFooter : System.Web.UI.UserControl, IFooterControl
Adding these to your code behind declarations will let the layout editors understand which controls to include in which lists.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

jasonhendee
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 42
Joined: Fri Apr 15, 2011 11:04 pm

Re: Left Sidebar in AC Gold (scriptlet in old version)

Post by jasonhendee » Wed Feb 27, 2013 6:14 pm

To save someone else frustration here, I wanted to point out an apparent bug (which I have logged using AC's new feedback tool within the admin panel).

I am using Gold R3 B5078, btw.

If you want to place your custom controls within a nested directory for organization (i.e. 'ConLib/Custom/'), the Edit Layout form within the admin panel will not properly mange these nested controls. When adding a given nested control to one of the "Selected Controls" list boxes, and clicking save, the control will be moved back over to the "Available Controls" list box, as if it didn't "take." Note that the control IS actually being added to appropriate Master Page, but the Edit Layout form doesn't see this because of a discrepancy in references to the control's name.

Here is how I fixed it if you're interested: I added a helper method to compare the controls' names properly:

Code: Select all

/// <summary>
/// Looks through a collection of ConLibControl(s) and returns the first instance whose name matches a supplied string
/// </summary>
/// <param name="controlName">The name of the control to look for</param>
/// <param name="controlCollection">The collection to look through</param>
/// <returns>A ConLibControl reference</returns>
// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name":
private ConLibControl FindSelectedControls(string controlName, ConLibControlCollection controlCollection)
{
    ConLibControl selectedControl = null;

    foreach (ConLibControl control in controlCollection)
    {
        string name = control.Name;
        if (name.Contains("/")) name = name.Substring(name.LastIndexOf("/") + 1);

        if (controlName == name)
        {
            selectedControl = control;
            break;
        }
    }

    return selectedControl;
}
// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name": End
and then called this method for each of the 4 possible control types:

Code: Select all

// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name":
//ConLibControl selectedControl = _HeaderControls.FirstOrDefault(control => control.Name.Equals(headerControl));
ConLibControl selectedControl = FindSelectedControls(headerControl, _HeaderControls);
// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name": End

Code: Select all

// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name":
//ConLibControl selectedControl = _SidebarControls.FirstOrDefault(control => control.Name.Equals(leftSidebarControl));
ConLibControl selectedControl = FindSelectedControls(leftSidebarControl, _SidebarControls);
// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name": End

Code: Select all

// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name":
//ConLibControl selectedControl = _SidebarControls.FirstOrDefault(control => control.Name.Equals(rightSidebarControl));
ConLibControl selectedControl = FindSelectedControls(rightSidebarControl, _SidebarControls);
// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name": End

Code: Select all

// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name":
//ConLibControl selectedControl = _FooterControls.FirstOrDefault(control => control.Name.Equals(footerControl));
ConLibControl selectedControl = FindSelectedControls(footerControl, _FooterControls);
// 2013-02-27:CFL_JPH - Nested controls were not being found because of the extra characters (the nested directory names) in their "name": End
Jason Hendee
Cables for Less

euroluxantiques
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Sat Dec 20, 2008 11:27 pm

Re: Left Sidebar in AC Gold (scriptlet in old version)

Post by euroluxantiques » Thu Feb 28, 2013 1:44 am

I've reported the nesting conlib problems several times myself. They totally don't work with the layout editor, so I end up making my layout changes directly in Visual Studio. I just installed R4, and it seems it didn't fix the problem there, either. I can see the custom controls in level ConLib/Custom/NonStandard but not at level ConLib/Custom. I use the NonStandard folder for 3rd party add-ons or things I write and the Custom level is just standard conlibs that I have modified a little. When I loaded R4 just now, None of the layouts that I have specified in the masters via Visual Studio are registering as selected controls. I'm not going to bother with selecting them now because I think it will just hose everything up and I will have to change the layouts manually again. This layout editor is buggy at best, and I've submitted several bugs and suggestions.

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

Re: Left Sidebar in AC Gold (scriptlet in old version)

Post by mazhar » Thu Feb 28, 2013 2:23 am

This cab easily fixed by makking few changes to Edit Layout page. Edit your Admin/Website/Layout/EditLayout.aspx.cs file and then do the following updates.

locate

Code: Select all

ConLibControl selectedControl = _HeaderControls.FirstOrDefault(control => control.Name.Equals(headerControl));
and update it

Code: Select all

ConLibControl selectedControl = _HeaderControls.FirstOrDefault(control => (control.Name.Equals(headerControl) || control.Name.EndsWith("/" + headerControl)));
locate

Code: Select all

ConLibControl selectedControl = _SidebarControls.FirstOrDefault(control => control.Name.Equals(leftSidebarControl));
and updated it

Code: Select all

ConLibControl selectedControl = _SidebarControls.FirstOrDefault(control => (control.Name.Equals(leftSidebarControl) || control.Name.EndsWith("/" + leftSidebarControl)));
locate

Code: Select all

ConLibControl selectedControl = _SidebarControls.FirstOrDefault(control => control.Name.Equals(rightSidebarControl));
and update it

Code: Select all

ConLibControl selectedControl = _SidebarControls.FirstOrDefault(control => (control.Name.Equals(rightSidebarControl) || control.Name.EndsWith("/" + rightSidebarControl)));
locate

Code: Select all

ConLibControl selectedControl = _FooterControls.FirstOrDefault(control => control.Name.Equals(footerControl));
and udpate it

Code: Select all

ConLibControl selectedControl = _FooterControls.FirstOrDefault(control => (control.Name.Equals(footerControl) || control.Name.EndsWith("/" + footerControl)));

jasonhendee
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 42
Joined: Fri Apr 15, 2011 11:04 pm

Re: Left Sidebar in AC Gold (scriptlet in old version)

Post by jasonhendee » Wed Mar 06, 2013 10:57 am

Mazhar,

Thank you for the LINQ-based fix; much less modification than mine :)
Jason Hendee
Cables for Less

Post Reply