Multilingual widget designer
Hi
I have a widget designer that contains a PageField that sits on a multilingual site. When I drop my control on a multilingual page I need to select a page from a localized list of pages but only see the structure for the default language.
I notice the PageField has a RootNodeID property which I guess if set will control this. Could you tell me the correct way of getting a localized root page?
Thanks
Brin
Hello Brin,
Actually, the culture is set on InitializeControls() as following:
protected
override
void
InitializeControls(GenericContainer container)
base
.DesignerMode = ControlDesignerModes.Simple;
base
.AdvancedModeIsDefault =
false
;
if
(
this
.PropertyEditor !=
null
)
var uiCulture =
this
.PropertyEditor.PropertyValuesCulture;
this
.PageSelectorControl.UICulture =
this
.PagesSelectorControl.UICulture = uiCulture;
var constantFilter = CommonMethods.GenerateSpecificCultureFilter(uiCulture,
"Title"
);
if
(!String.IsNullOrEmpty(constantFilter))
this
.PageSelectorControl.ConstantFilter =
this
.PagesSelectorControl.ConstantFilter = constantFilter;
this
.PageSelectorControl.AppendConstantFilter =
this
.PagesSelectorControl.AppendConstantFilter =
true
;
internal
static
string
GenerateSpecificCultureFilter(
string
uiCulture,
string
propertyName)
string
result =
null
;
var appSettings = Abstractions.AppSettings.CurrentSettings;
if
(appSettings.Multilingual)
var filterBuilder =
new
System.Text.StringBuilder();
filterBuilder.AppendFormat(
"(0[\"1\"] != null"
, propertyName, uiCulture);
if
(uiCulture == appSettings.DefaultFrontendLanguage.Name)
filterBuilder.AppendFormat(
" OR (0[\"\"] != null"
, propertyName);
var availableLangs = appSettings.DefinedFrontendLanguages.Select(l => l.Name);
foreach
(var lang
in
availableLangs)
filterBuilder.AppendFormat(
" AND 0[\"1\"] = null"
, propertyName, lang);
filterBuilder.Append(
")"
);
filterBuilder.Append(
")"
);
result = filterBuilder.ToString();
return
result;
Hi
Hi Brin,
Excuse me for misleading you. Actually, since you're developing a designer you can directly use the PageSelector control directly in it (no need of a field control). I have provided some additional information on the subject in your support ticket.
Greetings,