Get Page Menu Type Document Path Using Node ID Macro

Amy Patterson asked on February 18, 2022 00:57

There are times I set a repeater's content path to a child item or Page Menu item that exists on a different Page (Menu item) anywhere in the CMSTree, and all works well until a content editor decides to change the name of the page, which makes all the repeaters stop working until I check the page out and repoint the path to the renamed page. This can take up a lot of our time.

Since Node id never changes, is there a macro that can use just the Node id for a page type and return the Document Path, this way the repeater will get the content path and continue working no matter what the page name would be.

Recent Answers


Juraj Ondrus answered on February 18, 2022 13:10

I would recommend using GUID as the IDs can change. You can use the Documents macro method to get the node object. For example:

{% Documents[Documents.Where("NodeGUID = 'yourNodeGUID").FirstItem.NodeAliasPath].NodeAliasPath#%}

and you can replace the last NodeAliasPath with basically any node object field name.

0 votesVote for this answer Mark as a Correct answer

Amy Patterson answered on February 18, 2022 14:32

Juraj, The Macro works in the system application benchmark, but when I place in a repeater content path , it does not execute the macro on page load, is it possible to use a macro for a content path? Does it work for you?

0 votesVote for this answer Mark as a Correct answer

Amy Patterson answered on February 18, 2022 15:18

I just now got it to work, I was missing the /% at the end of the macro.

For anyone else trying to accomplish setting the path to a page using a page guid in a repeater webpart, or any web part that has a place to set a content path, it must end with /%

{% Documents[Documents.Where("NodeGUID = 'yourNodeGUID").FirstItem.NodeAliasPath].NodeAliasPath#%}/%

0 votesVote for this answer Mark as a Correct answer

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