Help displaying a Page Alias from a 3rd level?

Michael Purgar asked on March 5, 2019 18:17

Hello! I'm hoping someone can help me.

Based on a macro from a previous thread ( https://devnet.kentico.com/questions/get-page-name-where-web-part-is-located-with-macro ), I'm able to pull up the name of the parent of a particular branch of the content tree. So if the site is www.site.com/Level1/Level2/page.aspx the text that appears is Level1. So far, so good.

The macro I'm using is this one:

{% Documents["/" + CurrentDocument.NodeAliasPath.Split("/")[1]].DocumentName #%}

We now have a sub-site within the same tree whose base is represented as one level higher, so using the example above the text I would want to have appear would be Level2, but I cannot get that to display. The advice in the original thread is to change the [1] to a [2], but that change just causes no text to render at all.

Could anyone suggest what change would be needed in the macro - or perhaps a replacement for it - that would make it so we could display the page name value that appears at Level2? We're on Kentico v10.0.29 if that helps.

Thank you in advance!

Correct Answer

Rui Wang answered on March 5, 2019 18:55

When you call {% Documents["/" + CurrentDocument.NodeAliasPath.Split("/")[2]].DocumentName |(identity)GlobalAdministrator%}

1 votesVote for this answer Unmark Correct answer

Recent Answers


Rui Wang answered on March 5, 2019 18:51

By any chance you are trying to use this to display breadcrumb?

0 votesVote for this answer Mark as a Correct answer

Michael Purgar answered on March 5, 2019 19:29

Thank you sir!

It's sort of a breadcrumb, seen internally as a signal of what 'chapter' of the site the user is on.

I had been playing around with variations of the macro, and I think I was actually closing in on what you had posted, but I'm certainly grateful to have someone get me to the solution sooner rather than who knows how much later. Thank you again!

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on March 5, 2019 19:32

BTW, we do have breadcrumb control that you can use.

0 votesVote for this answer Mark as a Correct answer

Michael Purgar answered on March 5, 2019 19:44

We use the breadcrums elsewhere actually, but from a display standpoint this serves a slightly different purpose.

0 votesVote for this answer Mark as a Correct answer

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