Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save casper-rasmussen/5c5d80c4e0337f6389dd3def484dcf2d to your computer and use it in GitHub Desktop.
Save casper-rasmussen/5c5d80c4e0337f6389dd3def484dcf2d to your computer and use it in GitHub Desktop.
public override PartialRouteData GetPartialVirtualPath(CatalogContentBase content, string language, RouteValueDictionary routeValues,
RequestContext requestContext)
{
//Ensure that we don't include the section segment in our Commrece route lookup
object value;
bool found = routeValues.TryGetValue(SectionRouteValue, out value);
//Let's remove our section route value
routeValues.Remove(SectionRouteValue);
//Do a lookup via the HierachicalCatalogPartialRouter
PartialRouteData existing = base.GetPartialVirtualPath(content, language, routeValues, requestContext);
//Only allow it for Products
if(!(content is ProductContent))
return existing;
if (found)
{
//Get the name of our Section Segment
string sectionName = value as string;
if (!String.IsNullOrWhiteSpace(sectionName))
{
//Only supporting Sections that are included in our list
if (!this._segments.Contains(sectionName))
return existing;
return new PartialRouteData()
{
BasePathRoot = existing.BasePathRoot,
//Append the Segment to our URL
PartialVirtualPath = String.Format("{0}/{1}", existing.PartialVirtualPath, tabName)
};
}
}
//Resolve normally in case no Segment was included
return existing;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment