Get Nodes By Guid

Matthew Butler asked on June 29, 2022 10:23

What is the best practice way to retrieve Nodes for a given NodeGuid in Kentico 13, also If the purpose is just to get the NodeID do I need to specify Culture?

Correct Answer

Liam Goldfinch answered on June 30, 2022 13:30

Yeah wherever IPageRetriever is not available (like admin site), the next best alternative is to use DocumentHelper/DocumentQuery.

If the query is for a specific document type, you can use the generated Provider classes instead.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Liam Goldfinch answered on June 30, 2022 11:10 (last edited on June 30, 2022 11:12)

NodeID/NodeGuid are not culture specific, so if your website does use multiple cultures, ideally you would specify the culture to filter to the appropriate node.

If you were using DocumentID/DocumentGuid then you would not need to specify a culture as it is already culture specific.

You could do something like:

            var treeNode = DocumentHelper.GetDocuments()
            .WhereEquals(nameof(TreeNode.NodeGUID), /* pass node guid */)
            .Culture(/* pass culture code */)

You've mentioned that you only want the NodeID too, maybe restrict the columns being returned by adding: .Column(nameof(TreeNode.NodeID))

Since you're using Kentico Xperience 13, you might want to try alternative API methods of retrieving pages too, maybe look through

0 votesVote for this answer Mark as a Correct answer

Matthew Butler answered on June 30, 2022 13:22

Thanks Liam Goldfinch, Is DocumentHelper the best practice for Kentico 13 on the admin site?

I was hoping for something like IPageRetriever, but this seems to be aimed at the Content Delivery site

0 votesVote for this answer Mark as a Correct answer

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