Hi Trevor,
Last week I read an article you wrote and attempted to get dynamic routing working with your libraries. I was unsuccessful. The slugs in the admin site did not seem to generate and for the one's that did I couldn't seem to get the routing to work. I'm not totally sure what the slugs are doing and I was unsure of how to apply the dynamic routing attributes. Where do they go? the controller actions? the models? Big gap in my understanding. I would love to take another stab at it. Here's my current setup:
I've got a route like this:
routes.MapRoute(
name: "SomeTopLevelSiteSection",
url: "{*url}",
defaults: new { controller = "SomeTopLevelSiteSection", action = "SubPage" }
);
In the SubPage controller action looks like this:
public ActionResult SubPage()
{
var nodeAliasPath = HttpContext.Request.Path.Replace(HttpContext.Request.ApplicationPath, "");
var page = _treeNodeRepository.GetPageClassNameAndNodeGUID(nodeAliasPath);
if (page.ClassName == "MyCustom.GenericContent")
{
var treeNode = _genericContentRepository.GetGenericContent(page.NodeGUID);
var vm = GenericContentViewModel.GetViewModel(treeNode);
return View("_GenericContent", vm);
}
else // Page.ClassName == "MyCustom.ContentWithSideNav"
{
var treeNode = _contentWithSideNavRepository.GetContentWithSideNavPage(page.NodeGUID);
var pageVM = GenericContentWithSideNavViewModel.GetViewModel(treeNode);
foreach (var node in treeNode.Children)
{
var menuItem = new MenuItemViewModel { MenuItemText = node.NodeName, MenuItemRelativeUrl = node.NodeAliasPath };
pageVM.SideNavMenuItems.Add(menuItem);
}
return View("_ContentWithSideNav", pageVM);
}
}
That's a shortened version of the action as there are more types. How can I eliminate this type check?? My site's hierarchy has nodes 4-5 levels deep with varying page types throughout. As always, thanks for your help!