1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Multilingual widget designer

Multilingual widget designer

4 posts, 0 answered
  1. Brin
    Brin avatar
    18 posts
    Registered:
    04 Oct 2010
    13 Jul 2012
    Link to this post
    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
  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    18 Jul 2012
    Link to this post
    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
  3. Brin
    Brin avatar
    18 posts
    Registered:
    04 Oct 2010
    18 Jul 2012
    Link to this post
    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
  4. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    19 Jul 2012
    Link to this post
    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
4 posts, 0 answered