AI OnAI Off
What I've also tried to do, is in the ConvertToInternalInternal method, call:
base.ConvertToInternal(new UrlBuilder(url.Uri.AbsoluteUri.Replace("/Menu/", "/Products/")), out internalObject);
url.Path = url.Path.Replace("/Menu/", "/Products/");
however it doesn't seem to resolve to the correct internal page or url, even though the base.ConvertToInternal is finding the correct product internal object.
This works for me:
protected override bool ConvertToInternalInternal(EPiServer.UrlBuilder url, ref object internalObject)
{
if (url != null && (url.Path.ToLower().Contains("/test/")))
{
url.Path = url.Path.Replace("test", "articles");
}
return base.ConvertToInternalInternal(url, ref internalObject);
}
I hvae read the article Create a custom url rewrite provider, which has provided me with a good insite into how the provider works, and am now trying to modify to my requirements.
I am working with a menu and products with the following structure.
-- Menu
---- Category
---- Category 2
-- Products
---- Product 1
---- Product 2
I've been able to rewrite the outgoing links for products, i.e. /Products/Product1/ to /Menu/Product1, but I'm trying to map the /Menu/Product1/ to /Products/Product1.
In the example, it is assuming the url segment of the product(user) name, is not an actual page, whereas in my case, it is. Instead of loading a ProductDetailPage reference and setting an id, is there a simpler way?