Breadcrumb Redirect

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

Breadcrumb Redirect

Post by jsmits » Mon Nov 16, 2009 8:44 am

Does anybody know if it is possible to override the default NavigateUrl for a breadcrumb link?

Ideally, I'd like to do something like if CategoryId is x navigateUrl is y.

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

Re: Breadcrumb Redirect

Post by mazhar » Mon Nov 16, 2009 8:49 am

Possible solution could be to create a custom version of bread crumbs control which instead of pulling navigate URL through category try to map category id to some desired link. For this you would need to write some custom code how you will map category id to your custom URLs.

User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

Re: Breadcrumb Redirect

Post by jsmits » Mon Nov 16, 2009 12:05 pm

Thanks mazhar,

This is what the mod I made to categorybreadcrumbs for posterity's sake:

Code: Select all

    protected void Page_PreRender(object sender, System.EventArgs e)
    {
        HomeLink.NavigateUrl = NavigationHelper.GetHomeUrl();
        if (this.CategoryId != 0)
        {
            CommerceBuilder.Data.Database database = Token.Instance.Database;
            List<CatalogPathNode> path = CatalogDataSource.GetPath(CategoryId, true);
            foreach (CatalogNode node in path)
            {
                string sql = ("SELECT * FROM js_BreadCrumbsMapping WHERE CategoryId = ") + node.CatalogNodeId;
                using (System.Data.Common.DbCommand selectCommand = database.GetSqlStringCommand(sql))
                {
                    DataSet ds = (DataSet)database.ExecuteDataSet(selectCommand);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string navUrl = "~/" + (string)ds.Tables[0].Rows[0]["NavigateUrl"];
                        string name = (string)ds.Tables[0].Rows[0]["Name"];
                        HyperLink BreadCrumbLink = new HyperLink();
                        BreadCrumbLink.NavigateUrl = navUrl;
                        BreadCrumbLink.Text = name;
                        BreadCrumbsRepeater.Controls.Add(new LiteralControl("&nbsp;>&nbsp;"));
                        BreadCrumbsRepeater.Controls.Add(BreadCrumbLink);
                        if ((HideLastNode) && (BreadCrumbsRepeater.Controls.Count > 0))
                        {
                            BreadCrumbsRepeater.Controls[(BreadCrumbsRepeater.Controls.Count - 1)].Visible = false;
                        }
                    }
                }
            
            }   
       }
       else BreadCrumbsRepeater.Visible = false;
    }
I am new to C# so apologize if my code is a bit untidy.

Post Reply