Hi, I am attempting to find the NodeAliasPath from within a controller and am having some issues. I have tried using the following code snippets which I found on this forum.
// Ways to get current page
string nodeAliasPath = CurrentDocument.GetValue("NodeAliasPath").ToString();
string nodeAliasPath = CMS.DocumentEngine.DocumentContext.CurrentAliasPath;
// Ways to get parent page
string parentNodeAliasPath = CurrentDocument.Parent.GetValue("NodeAliasPath").ToString();
The idea is to get the NodeAliasPath dynamically and to use it to get the content for nested pages etc...
My question is, when and where is the Node Alias Path available? I have tried calling it in models, views, controllers. It returns null or empty string every time.
I can see in the CMS that it does exist, and I can even use a hard coded alias path in my code, but it won't find it dynamically.
This is an example of how I am trying to get it in the controller. I feel like I'm not thinking about this in the Kentico way.
Thanks
PeoplePage peopleNode = PeoplePageProvider.GetPeoplePage("/ADIA-People", "en-us", "Adia")
.Columns("DocumentName", "Title", "Heading", "Copy", "Image");
ViewBag.aliaspath = peopleNode.NodeAliasPath;