AI OnAI Off
Hi Siddharth,
I have created another entry for Node in the RouteTable which works for both cases catalog and node. Please try.
e.g.
www.example.com/shopping/testnode/cookware/
www.example.com/testnode/cookware/
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class CatalogRoutingInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
// Services
ReferenceConverter referenceConverter = context.Locate.Advanced.GetInstance<ReferenceConverter>();
IContentLoader contentLoader = context.Locate.Advanced.GetInstance<IContentLoader>();
// Register catalog router (removes catalog string from URL)
ContentReference rootLink = referenceConverter.GetRootLink();
CatalogContent catalog = contentLoader.GetChildren<CatalogContent>(rootLink).FirstOrDefault();
Func<ContentReference> startLink = () =>
ContentReference.IsNullOrEmpty(SiteDefinition.Current.StartPage)
? SiteDefinition.Current.RootPage
: SiteDefinition.Current.StartPage;
// catalog root content
RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(startLink, catalog, false));
// node root content
var rootNodeContent = contentLoader.GetChildren<NodeContent>(catalog.ContentLink).FirstOrDefault();
var nodeCatalogContent = contentLoader.Get<CatalogContentBase>(referenceConverter.GetContentLink(rootNodeContent.Code));
RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(() => rootNodeContent.ContentLink, nodeCatalogContent, false));
}
public void Uninitialize(InitializationEngine context)
{
}
}
For more customization please follow Jakejon's post.
It looks like you are using Foundation? Then you might want to remove this line
this registers the default router which might interfere with your set up
Hi,
I am trying to set the Node content as the catalog root. Below is my catalog structure:
https://www.screencast.com/t/5tMhOWSBJDk
I want to make the Test Node the root for all the children Node Contents under it. And below is my code
But I still see the routing has not changed, it still is for exmaple: www.example.com/shopping/testnode/cookware/
Since I made the the first NodeContent the root, I was expecting it to be like: www.example.com/testnode/cookware/
Am I missing something here?