Site structure
Version 4.x > Site structure > retrieving document url View modes: 
User avatar
Member
Member
sales-bluweb.co - 1/31/2010 11:56:36 AM
   
retrieving document url
Hope someone can help me.

I'm trying to provide a mailto link on the selected news item transformation page. When I use Request.ServerVariables["URL"] i get NewsPage.aspx rather than Home/News/news-article-title!!.aspx. Is there anyway to retrieve this value? I've looked through the CMSContext object but couldn't find anything other than documentname but this doesnt give me the correct format for the url.

Any help much appreciated.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 2/1/2010 4:48:21 AM
   
RE:retrieving document url
Hello,

I am a bit confused. Could yoyu please give me an example of how the link should look?
You can get the current url of the document by using the following code:

<%# GetDocumentUrl() %>

Best regards,
Boris Pocatko

User avatar
Member
Member
sales-bluweb.co - 2/1/2010 12:44:06 PM
   
RE:retrieving document url
Basically I need to access this in code behind.. not as databind expression. I have a cmsrepeater on a page which displays news articles as well as displays the selectedtransformation once a news article is selected. I need to retrieve the documenturl in code behind so I can write the mailto link in the page - once a user has selected a news item. hope this makes sense.

User avatar
Member
Member
sales-bluweb.co - 2/2/2010 1:57:55 PM
   
RE:retrieving document url
OK I've managed to get the document url in code behind using

CMS.CMSHelper.CMSContext.GetDocumentUrl(CMSContext.CurrentDocument.DocumentID))

The problem is the format is incorrect. If a comma (') for example appears in the url this is replaced with a dash (-). How do I ge the proper url? It seems as if it is being encoded once it's been retrieved.

Hope someone who can help me.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 2/2/2010 2:06:55 PM
   
RE:retrieving document url
Hello,

Some characters are forbidden in URLs and thus they are replaced with a safe character (by default, it's dash -). You can specify the forbidden characters and the replacement character in Site Manager -> Settings -> URLs, in values "Forbidden characters replacement" and "Forbidden URL characters". The retrieved link should still be valid.

Best regards,
Boris Pocatko

User avatar
Member
Member
sales-bluweb.co - 2/15/2010 1:24:31 PM
   
RE:retrieving document url
Thanks