Get Parent URL in News.Detail

Alex Pl asked on February 19, 2015 09:08

HI, I've added news.list, and news.detail on my website.

I'm looking for any possibility to get URL of parent document - from news.detail to news.list.

I've used the ascx transformation type.

So far i've add link to the present document:

<a href="<%# GetDocumentUrl() %>" class="back_to_prev">

I also tried with:

<a href="<%# GetDocumentUrl(CurrentPageInfo.NodeParentID) %>" class="back_to_prev">

But this creates links to random pages.

Correct Answer

Petar Kozjak answered on February 19, 2015 13:11

Hi,

try <%# CMS.DocumentEngine.DocumentContext.CurrentDocumentParent.AbsoluteURL %>

2 votesVote for this answer Unmark Correct answer

Recent Answers


Adam Gitin answered on February 19, 2015 11:47

try:

<%# CurrentDocument.Parent["ColumName"] %>

0 votesVote for this answer Mark as a Correct answer

Alex Pl answered on February 19, 2015 12:52 (last edited on February 19, 2015 12:52)

In my case Your code display url of a present page (not parents).

I've also tried:
DocumentContext.CurrentDocumentParent.AbsoluteURL #

This worked on the "web part properties" window, for example in "content before" field, but in Transformation that code generated errors (problem with DocumentContext). Do I have to change the "Transformation type" to "text/xml"?

1 votesVote for this answer Mark as a Correct answer

Alex Pl answered on February 19, 2015 13:22

Thanks! That code works fine.

0 votesVote for this answer Mark as a Correct answer

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