The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
public
class
LanguageSelectorCustom : LanguageSelectorControl
{
public
bool
AppendDetailItemOnLanguageChange
{
get
{
return
defaultValue;
}
set
{
this
.defaultValue = value;
}
}
private
bool
defaultValue =
true
;
LanguageSelectorControl
- this is where we resolve the absolute page URL for the available languages.var url =
base
.GetUrlForLanguage(ci);
if
(AppendDetailItemOnLanguageChange && !
this
.IsDesignMode())
{
//get detail item URL parameter
var paramString =
this
.GetUrlParameterString(
false
);
if
(!paramString.IsNullOrEmpty())
{
//get the detail item UrlName
var detailItemUrl = paramString.TrimStart(
'/'
);
//get the actual item that matches this UrlName
var providerName = String.Empty;
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
Type projectType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.Projects.Project"
);
var matchingItem = dynamicModuleManager.GetDataItems(projectType)
.Where(di => di.UrlName == detailItemUrl
&& di.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
.SingleOrDefault();
if
(matchingItem !=
null
)
{
//set culture to langName
var tempCI = CultureInfo.CurrentUICulture;
Thread.CurrentThread.CurrentUICulture = ci;
//get UrlName for culture
var urlNameForLanguage = matchingItem.UrlName[ci];
//set back original culture
Thread.CurrentThread.CurrentUICulture = tempCI;
//Resolve the page URL and append the detail item URL to it
url = RouteHelper.ResolveUrl(url, UrlResolveOptions.Absolute);
url +=
"/"
+ urlNameForLanguage;
Boyan Barnev is a Principal Information Developer at Progress. His mission is to demonstrate the unlimited capabilities of Sitefinity CMS via product documentation, SDK samples, and technical blog posts. He has graduated from the American University in Bulgaria and joined Telerik in 2011. Since then Boyan has held various positions in the company, leading the strategy and operation of the Sitefinity CMS Technical support service worldwide.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.