Reputation: 12998
According to How localization works I can translate pages and give them a different URL for every language.
Example from the tutorial:
http://butterflysite.co.uk/en-GB/Home/contact/Newoffice.aspx
(english)http://vlindersite.nl/nl-NL/thuis/contact/NieuwKantoor.aspx
(dutch)My question is now: Assuming I know which language I am currently in, how do I find out what the URL title for my page is in C#?
What is the best way to use the C1 API to create the correct link to the page in the current language?
Upvotes: 1
Views: 319
Reputation: 1308
Variant No1
public string GetPageUrl(Guid pageId, CultureInfo locale)
{
using(var conn = new DataConnection(PublicationScope.Published, locale))
{
var pageNode = new SitemapNavigator(conn).GetPageNodeById(pageId);
return pageNode != null ? pageNode.Url : null;
}
}
Variant No2
public string GetPageUrl(Guid pageId, CultureInfo locale)
{
var pageUrlData = new PageUrlData(pageId, PublicationScope.Published, locale);
return PageUrls.BuildUrl(pageUrlData, UrlKind.Public, new UrlSpace());
}
Upvotes: 1
Reputation: 106
atticae, have a look to the CurrentPageNode - @CurrentPageNode.MenuTitle
Upvotes: 0