Get a document URL of a specific page

Jason Vaughan asked on June 10, 2016 22:24

How can you get a url of a specific page that is NOT your current document. I know how to get a url for the specific page that I am on, but I want to basically pick and choose which page I want to get the link for.

Thanks!

Recent Answers


Brenden Kehren answered on June 11, 2016 04:20

What other object or key value do have to use? Where are you needing this? A transformation? Just somewhere in an API call?

0 votesVote for this answer Mark as a Correct answer

Jason Vaughan answered on June 11, 2016 04:59

I am trying to do this at the header level of a hierarchical menu transformation. I am new to kentico, so I am still learning. Wasn't sure if there was a specific macro that I could be using? If you look back at my most previous question it will be for the same root menu item that I was asking about how to get there. Essentially I want to do like Getdocumenturl(pass something in). I know how to pass on the current document, but wasn't sure how to get the Url for any page I want from anywhere.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on June 11, 2016 05:36

For a Hierarchical transformation a Header and Footer transformation type don't have any page type data associated to them. If you're familiar with how a standard asp.net repeater works, it would be the Header and footer of the repeater, there is no dataview in either of those.

There are functions to get URLs but you need to have something like a nodeID or a documentID or some other piece in order to get back. So if you are in the header or footer it will not work. Your best bet is to do a First and Last transformation.

0 votesVote for this answer Mark as a Correct answer

Jason Vaughan answered on June 11, 2016 12:20

I thought of that, but my problem is I had to manually add my first list item to the HTML before section of the menu control. Reason for that is because the way I had my path set up my root menu item wouldn't appear in the menu, so I had to manually add it.

Example: Home / Programs & Courses / Academics (WANT SET TO ROOT OF BELOW LIST)

(How list currently appears, but wanted to add "Academics") as top menu item) * Academic Departments * Accounting * Business * Chemical Dependency Counseling * Credit Programs

I set my path of the menu to /{0}/{1}/{2}/%, so the menu will always start at the "Academic" level, but with doing that never actually includes that level on my list, but only its children. So, because I wanted that level added I manually got the text to display, but wasn't sure how to get its URL since it's not really considered the "first" item in the hierarchical menu.

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on June 11, 2016 13:37

I would use some other web part like Static text to render those parent itemes, but if you want to render all of them in your hierarchical viewer, set the path to select all pages /% and specify where condition like this:

NodeAlisPath='/{%NodeAliasPath.Split("/")[1]%}' or NodeAlisPath='/{%NodeAliasPath.Split("/")[1]%}/{%NodeAliasPath.Split("/")[2]%}' or NodeAlisPath like '/{%NodeAliasPath.Split("/")[1]%}/{%NodeAliasPath.Split("/")[2]%}/{%NodeAliasPath.Split("/")[3]%}%'
0 votesVote for this answer Mark as a Correct answer

Jason Vaughan answered on June 11, 2016 15:10

Thank you I will try that. For the where clause are you saying to put that whole statement including all the or's or just pick one of the them?

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on June 13, 2016 15:47

All of it :-)

0 votesVote for this answer Mark as a Correct answer

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