Developer forum

Forum » CMS - Standard features » Page URL template tag

Page URL template tag

Denys Ubizskyy
Reply

Hi,

Lets say I have a page:

www.mysite.com/area/customers/customers-about-us.aspx

I am trying to get page url in a format

/customers/customers-about-us.aspx

(without domain name and language area) with some template tag.

Have tried:

<!--@Global:Pageview.Url-->
<!--@Global:Request.Url-->
<!--@Global:Pageview.Url.Raw-->
<!--@Global:Request.AbsoluteUri-->
<!--@Global:Request.PathAndQuery-->
<!--@Global:Request.OriginalString-->

but all of them returns URL in not appropriate format.
Does anyone have any suggestions?

Thank you in advance.

 


Replies

 
Nicolai Høeg Pedersen
Reply

For which usage?

 

Usually you should never write out URLs in the friendly format. You should always use the format Default.aspx?ID=123 and let DW handle the rest.

 

In this example the URL for the page is /area/customers/customers-about-us.aspx and not /customers/customers-about-us.aspx and therefore it is not available.

 

But if you give me a couple of hints on the context you need to use it in, I can help.

 

One option of course is to use Razor based template (8.2.3+) and in there you have full .NET support and can use string manipulation and Dynamicweb API to obtain exactly what you want.

 

BR Nicolai

 
Denys Ubizskyy
Reply

Thanks for reply Nicolai.

I need this to insert alternate links into meta data of a page.
We have a lot of pages with same path and quite similar content on different sites and it would be great if we could insert few alternate links.

For some page

http://www.mysite.com/usa/customers/customers-about-us.aspx
 

set of such links could look like

<link rel="alternate" hreflang="en" href="http://www.mysite.com/usa/customers/customers-about-us.aspx" />
<link rel="alternate" hreflang="en-gb" href="http://www.mysite.co.uk/uk/customers/customers-about-us.aspx" />
<link rel="alternate" hreflang="en-au" href="http://www.mysite.com.au/au/customers/customers-about-us.aspx" />


But here I need to get somehow the part of URL without domain name and language area somehow.

 

 
Nicolai Høeg Pedersen
Reply

I have no good easy way.

 

Change to Razor and do some scripting there, or make a pagetemplate extender and make the tag there...

 

BR Nicolai

 
Denys Ubizskyy
Reply

Hi Nicolai,

thanks for you help. I have experimented with razor locally and I liked it. I'd like to upgrade our production to make Razor available (currently we run 8.2.1.8 version). But here comes another question: is it safe to update to 8.2.3 version? Seems like it is quite unstable yet.

Thank you once again.

 

 
Nicolai Høeg Pedersen
Reply

Hi Denys

 

Yes it is. There will a hotfix later today. That one should be stable enough to put into production.

 

BR Nicolai

 

You must be logged in to post in the forum