Try our conversational search powered by Generative AI!

Populate a dropdownlist dinamically (with country/language)

Vote:
 

Hi,

I would like to be able to populate a dropdownlist dinamically (with country/language), with the following requirements:

- The selection of a country/language, must go to www.xxxx.com/language/startpage (for the specified country).
- If I add another language to the xxxx website, it automatically must appear as an element of the dropdownlist.
- By default, the inicial starting page must depend on the IP of the connected client. For example, if I'm connecting from Italia, the initial starting page must go to
I've four qüestions about this issue:
1) Is it possible to accomplish such requirements?
2) if not, how do you suggest to implement such functionality? 
3) Do you know some real episerver websites with such functionality?
#135831
Sep 16, 2015 10:35
Vote:
 

Hi,

I think that you could use LanguageBranchRepository:

            var languageBranchRepository = ServiceLocator.Current.GetInstance<ILanguageBranchRepository>();
            var languageBranches = languageBranchRepository.ListEnabled();
            foreach (var languageBranch in languageBranches)
            {
                
            }

This code returns all enabled languages.

Or you could use domain mappings. To get currently enabled languages you could use the code:

            var siteDefinition = SiteDefinition.Current;
            foreach (var hostDefinition in siteDefinition.Hosts)
            {
                //hostDefinition.Language
            }

The site definition contains host. And ech host have language.

#136156
Sep 17, 2015 1:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.