Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • maarten 10 posts 30 karma points
    Mar 19, 2012 @ 14:27
    maarten
    0

    So instead of having a dropdownbox, I'd like it to be plain text like this :

    NL | FR | EN

    How can I do this ?

  • dimi309 244 posts 578 karma points
    Mar 19, 2012 @ 16:04
    dimi309
    0

    Hello maarten,

    You could replace the default language selector by your own if you download the source code from Codeplex and take a look at the existing selectors as an example. The selectors are two user controls: LanguageSelector.ascx and LanguageSelectorForWebForm.ascx (for when web forms are used) together with their corresponding codebehinds (.ascx.cs files).

    Thanks for taking an interest in this package! By the way, if you develop your own version of the selector and would like to contribute it, please feel free to create a pull request on Codeplex.

    Best regards,

    Dimitri

     

  • maarten 10 posts 30 karma points
    Mar 20, 2012 @ 09:21
    maarten
    0

    Thanks Dimitri, I'll give it a try and post the result later ! 

  • maarten 10 posts 30 karma points
    Mar 22, 2012 @ 09:21
    maarten
    0

    Hi Dimitri,

    I've started making some adjustments to the source code, but how do I 'rebuild' the package with my adjustments?

    Thank you!

  • dimi309 244 posts 578 karma points
    Mar 22, 2012 @ 17:58
    dimi309
    0

    Hello Maarten,

    If you have downloaded the source solution from Codeplex, you need just one more thing before you can rebuild it. The project references some Umbraco dlls, and the references to them will probably be broken. I do not redistribute these dlls, since I have not built them myself but you can use the ones from your Umbraco installation.

    So, to do this simply, you would need to create a folder called UmbracoBinaries inside the Dimi.Polyglot project folder and copy the dlls from your Umbraco installation there. If you still get errors due to missing references, you could just re-add the references that appear to be broken (I think they will have a yellow sign over them in Visual Studio).

    Once you have managed to rebuild the project's dll, you can copy it into your Umbraco installation's bin folder (I hope that you do this on a test version first:)). If you modify files other than the binary, you need to copy those in the respective Umbraco folders, over the ones initially installed by the package.

    I hope that this helps! (And that I have not confused you further:))

    cheers

    Dimitri

     

  • maarten 10 posts 30 karma points
    Mar 26, 2012 @ 10:49
    maarten
    0

    Hi Dimitri, I'm close to finding a solution but I could really use your help.

    This is the code I have so far :

    private void ShowLanguages()
            {
                var redirectQs = new QueryString(Page);
                redirectQs.RemoveParameter("lang");
     
                var jsRedirect = redirectQs.AllUrl;
                if (redirectQs.Parameters.Count == 0) jsRedirect += "?lang=";
                else jsRedirect += "&lang=";
     
                var sb = new StringBuilder();
     
                //sb.Append("<a href='" + redirectQs.AllUrl + "'>NL</a>");
                sb.Append("<form method=\"get\" action=\"" + redirectQs.AllUrl + "\">");
                foreach (string key in redirectQs.Parameters.Keys)
                {
                    sb.Append("<input type=\"hidden\" name=\"" + key + "\" value=\"" + redirectQs[key] + "\" />");
                }
     
              //  sb.Append("<select id=\"LanguageDropDownList\" name=\"lang\"  onchange=\"javascript:location='" + jsRedirect +
              //            "' + this.options[this.selectedIndex].value\" >");
                sb.Append("<div id='LanguageDropDownList'>");
     
                foreach (var language in AvailableLanguages)
                {
                    var selected = string.Empty;
                    if (language.ISOCode == SelectedLanguage.ToLower())
                        selected = " selected=\"selected\" ";
                    sb.Append("<a href=\"javascript:location='" + jsRedirect +
                          "' + this.options[this.selectedIndex].value\" >" + language.ISOCode + "</a>");
                }
     
                sb.Append("</div>");
                //sb.Append("<noscript><input type=\"submit\" value=\"&gt;\" /></noscript>");
                sb.Append("</form>");
                LanguageDropDownListLiteral.Text = sb.ToString();
            }

    I'm almost getting the desired result. I'm seeing this on the website : nlfren. So it means he can find the languagues. But I'm having trouble with the links.

    This is the HTML code after the website is rendered: 

    <div id="LanguageSelector">
     
                <form method="get" action="/"><div id='LanguageDropDownList'><a href="javascript:location='/?lang=' + this.options[this.selectedIndex].value" >nl</a><a href="javascript:location='/?lang=' + this.options[this.selectedIndex].value" >fr</a><a href="javascript:location='/?lang=' + this.options[this.selectedIndex].value" >en</a></div></form>
     
    </div>

    So the javascript I copied from your code doesn't appear to work in an anchor tag. I could really use some help with this, and I hope you understand the problem!

    Thank you in advance!

  • dimi309 244 posts 578 karma points
    Mar 26, 2012 @ 22:48
    dimi309
    0

    Hi Maarten,

    It seems that the javascript code entered into the href does not link to the location indicated by the this.options statement. How about adapting the this.options statement, putting it in a javascript function and calling that one from the href? Or even better, how about not using javascript at all and just rendering the whole URL that each link will point to using your C# code?

    Best regards,

    Dimitri

  • maarten 10 posts 30 karma points
    Mar 27, 2012 @ 15:59
    maarten
    0

    I don't really understand what you mean with rendering the whole link using my C# code?

     

    I'll give the other option a try!

  • maarten 10 posts 30 karma points
    Mar 28, 2012 @ 13:27
    maarten
    0

    Hi Dimitri,

    I've tried the javascript option but I can't get it to work. Could you perhaps explain the other option more?

    Thanks!

  • dimi309 244 posts 578 karma points
    Apr 03, 2012 @ 09:06
    dimi309
    0

    Hi maarten,

    I am sorry for the delay but I am away on a trip and I have limited access to the Internet. As far as the other option is conerned, I meant that you can produce links in c# pointing directly to urls, for example a href="somepage.on.the.site" instead of creating the links in javascript using a href="javascript:location etc" like you do now. Appart from resolving your current issue, this method will also make your site run properly in the event that a visitor has disabled javascript in his or her browser. This is what I do in the source code of the package too, so you can have a look at the codebehind of the language selector control If you need an example of how to do it.

    Best regards,
    Dimitri

Please Sign in or register to post replies

Write your reply to:

Draft