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

Forums / Developing with Sitefinity / Smart localization links

Smart localization links

2 posts, 0 answered
  1. Pamela Thalacker
    Pamela Thalacker avatar
    14 posts
    Registered:
    25 Feb 2010
    25 Feb 2010
    Link to this post
    I have the code from this forum post that explains how to replace the LanguageBar dropdown with hyperlinks.  That gets me halfway where I need to be, but I am wondering what would be involved in having the linklist control check to see whether there is localized version of the page available and display links only when their is a localized version of the page.

    Also, if I uses the links will the behavior be the same as with the dropdown.  If someone clicks on a localized link, then the navigation will be reduced to only those pages that have a translation?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Mar 2010
    Link to this post
    Hello Pamela Thalacker,


    You need to create a custom control that is populated only with the language versions that are available

    sample code

    //GET THE CURRENT PAGE id
    Guid pageID = new Guid(this.Context.Items["cmspageid"].ToString());
    var Manager = new CmsManager();
    ICmsPage cmsPage= (ICmsPage)Manager.GetPage(pageID, true);
    if (!Page.IsPostBack)
    {
        foreach (IPageContent version in cmsP.LanguageVersions.Values)
        {
            int cultur = version.LangID;
            CultureInfo culture = new CultureInfo(cultur);
            string languageName = culture.Name;
            ListItem item = new ListItem();
            item.Value = languageName;
            item.Text = languageName;
            if (String.IsNullOrEmpty(item.Text))
            {
                // return def culture you can use LocalizationManager
                item.Text = "en";
            }
            // ADD THE ITEMS TO A LIST
     
        }
    }

    Another option is removing the list items from the list depending on the available versions. This way is simpler than the first one. Again you need to get the current page and use CmsManager as shown above, then check the list items using for loop. You will find a sample code in this forum post - Language "Toggle"

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered