Finding the NodeAliasPath after retreiving a node/page type

S1T2 Developer asked on October 25, 2019 06:26

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.


PeoplePage peopleNode = PeoplePageProvider.GetPeoplePage("/ADIA-People", "en-us", "Adia")
                            .Columns("DocumentName", "Title", "Heading", "Copy", "Image");

ViewBag.aliaspath = peopleNode.NodeAliasPath;

Recent Answers

S1T2 Developer answered on October 25, 2019 07:47

I now understand what I have done wrong, I was limiting the search to particular columns, but not specifying the NodeAliasColumn.

Let me know if anyone sees anything else that might be of interest. Thanks.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.