How to get a Documents URL via Query Webpart

Kevin Kim-Murphy asked on May 13, 2015 21:58

Hi. I am attempting to write a transformation that retrieves the URL for a given document (page) from the data retrieved via a custom query in a Query Data Source web part.

While the custom query has a number of conditions for retrieving the appropriate data, once those conditions are met the query states: SELECT * FROM custom_table_name

I have been attempting to use standard URLs and Page Link transformations - found here: https://docs.kentico.com/display/K82/Reference+-+Transformation+methods;jsessionid=CB42D5491B7DAC1D3A87FA38C72260A9#Reference-Transformationmethods-URLsandpagelinks

The two I have tried with no luck are: GetDocumentUrl and GetDocumentLink.

I also tried Eval("DocumentUrlPath") but that only displays the URL of the page I am currently on - not the URL of the Page the data is pulling from.

This seems like a relatively straightforward issue - but I have been unable to find the answer in Kentico's Devnet.

Thank you in advance for any assistance you can provide.

Kevin

Recent Answers


Brenden Kehren answered on May 13, 2015 22:01

Using <%# Eval("NodeAliasPath") %> will return the path of the document being rendered.

Using <%# CurrentDocument.NodeAliasPath %> will return the path of the document you are navigating to.

0 votesVote for this answer Mark as a Correct answer

Kevin Kim-Murphy answered on May 13, 2015 22:17

Brenden,

Thanks for the quick reply. Unfortunately both of those pull the path of the current page.

Basically from the page I am on I am pulling in a list of related pages based on a number of conditions. All of the related pages are from one page type: custom.tour_leaders. And I basically am pulling all of the data about these "tour leaders" to display in this list - i.e. name, title, photo and URL (a link to the Tour Leader's page). The URL is the only thing NOT working.

I hope that helps clarify the situation I am currently facing.

Thanks again!

0 votesVote for this answer Mark as a Correct answer

Charles Matvchuk answered on May 14, 2015 02:13 (last edited on May 14, 2015 02:21)

Since you are using a custom query you will need to create your own code to resolve. The transformation, doesn't know that the data is coming from a page type or document type. Or use the transformation method's below to resolve., see the overloaded methods as well.

<%# GetDocumentUrl() %>
<%# GetDocumentUrl(Eval("DocumentID")) %>
<%# GetDocumentUrl(Eval("NodeGUID"), Eval("NodeAlias")) %>
0 votesVote for this answer Mark as a Correct answer

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