Multilingual widget designer

Posted by Community Admin on 04-Aug-2018 10:27

Multilingual widget designer

All Replies

Posted by Community Admin on 13-Jul-2012 00:00

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

Posted by Community Admin on 18-Jul-2012 00:00

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;
               
           
       

Since PageField contains a Page selector, you can access the PageSelector and set its UI culture through the UICulture property. Note that after that, we use the GenerateSpecificCultureFilter() method to filter pages, depending on the culture, specified in the query string. You need to implement your own filtering, based on this method in order to filter pages:

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;
        

Kind Regards,
Jen Peleva
The Telerik Team

Posted by Community Admin on 18-Jul-2012 00:00

Hi 

Thanks for your response, however the PageField does not contain properties named UICulture, ConstantFilter or AppendConstantFilter.

The PageField has been set up as follows:

http://www.sitefinity.com/blogs/joshmorales/posts/11-10-05/selecting_sitefinity_4_content_inside_widget_designers.aspx

You mention that the PageField contains a PageSelector however this is internal so not accessible by the designer. Any thoughts?

Thanks again

Brin

Posted by Community Admin on 19-Jul-2012 00:00

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,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed