Smart Search searchResultItem.Data.GetValue(nameof(TreeNode.NodeAliasPath) not working

Pete Capp asked on March 13, 2024 15:01

searchResultItem.Data.GetValue(nameof(TreeNode.NodeAliasPath) When I get the data from the returned search item and try and get the NodeAliasPath for adding a link to the found item, the data object will not return the NodeAliasPath or AliasPath or anything in the Data object. nameof(TreeNode does not recognize TreeNode or anything in the object. Is there another way to do this?

Correct Answer

Brenden Kehren answered on March 15, 2024 15:46

It depends on where you get that property. If you're getting the property in a controller or data access class, then you'd use something like:

pageUrlRetriever.Retrieve(nodeAliasPath, culture, SiteContext.CurrentSiteName).AbsoluteUrl

If you're in a view, you'd use something like:

@Url.Kentico().PageUrl(modelObject.NodeAliasPath)

0 votesVote for this answer Unmark Correct answer

Recent Answers


Pete Capp answered on March 13, 2024 21:52

@item.Data.GetProperty("NodeAliasPath") The above will get the NodeAliasPath, but this is not always the routed path.

How do we get that?

0 votesVote for this answer Mark as a Correct answer

Pete Capp answered on March 18, 2024 15:02

Thank you, @Url.Kentico().PageUrl(modelObject.NodeAliasPath) is what I was looking for and could not find.

0 votesVote for this answer Mark as a Correct answer

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