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.
Breadcrumb Redirect
Re: Breadcrumb Redirect
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.
Re: Breadcrumb Redirect
Thanks mazhar,
This is what the mod I made to categorybreadcrumbs for posterity's sake:
I am new to C# so apologize if my code is a bit untidy.
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(" > "));
BreadCrumbsRepeater.Controls.Add(BreadCrumbLink);
if ((HideLastNode) && (BreadCrumbsRepeater.Controls.Count > 0))
{
BreadCrumbsRepeater.Controls[(BreadCrumbsRepeater.Controls.Count - 1)].Visible = false;
}
}
}
}
}
else BreadCrumbsRepeater.Visible = false;
}