We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21778
    • 223 Posts
    Hey guys, im want to have a function where a user can switch language on my site by clicking a button(flag).

    Any good snippet or idea that works with the newest modx version, i could use for this? =)

    Thanks!
      • 10608
      • 36 Posts
        • 21778
        • 223 Posts
        Thanks seems nice and easy.

        One problem, the redirect only works in firefox, not any of the others
          • 22851
          • 805 Posts
          In case you haven’t come across/considered it, there is a multilingual solution for MODx called YAMS. Depending on how your prefer to structure your site and what kind of URLs you want it might be more appropriate. Difficult to say whether it’s ’easier’ or not. If you decide to try it, I recommend going for the latest alpha version referred to in the head forum post for YAMS.
            YAMS: Yet Another Multilingual Solution for MODx
            YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
            Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
            • 21778
            • 223 Posts
            Quote from: PMS at Sep 21, 2009, 04:03 AM

            In case you haven’t come across/considered it, there is a multilingual solution for MODx called YAMS. Depending on how your prefer to structure your site and what kind of URLs you want it might be more appropriate. Difficult to say whether it’s ’easier’ or not. If you decide to try it, I recommend going for the latest alpha version referred to in the head forum post for YAMS.

            Okay I’m currently working on getting YAMS to work on my site.
            It’s a little overwhelming for a modx rookie as me though smiley

            I have followed the instructions on installation 1-6
            and have also installed "managermanager" and hopefully edited it correct according to YMAS installation guide.

            I’m not 100% sure what to do now..
            I want to have the site in Danish and Føroyski (another nordic language that uses same charset as the danish).

            Is it possible to get the menu is both languages as well? And how do i create the button for switching language?

            Thanks smiley
              • 22851
              • 805 Posts
              PaulSuckling Reply #6, 17 years ago
              @norlin

              Thanks for sending me a personal message with your site details.

              I noticed that you had copied/written plain text comments into the YAMS plugin and mm_rules chunk, which was breaking things. Snippets and Modules are PHP code. Since the comments weren’t recognised as code , this was breaking things. In PHP every comment line needs to be preceded by a double slash //, or alternatively blocks of comments can be wrapped /* like so */

              MODx chunks can contain whatever you like, generally HTML, but the mm_rules chunk happens to contain PHP code too, so the same rules about comments apply.

              SO, I have fixed your ManagerManager config for you and your multilingual documents now have a tabbed interface. The next step is to go to Modules > YAMS > Language Settings and set up your languages. I suggest first adding your extra languages, then making one of them the default language, then deleting the unwanted ones.

              Finally, back to your original questions. To get a multilingual menu, you need to add the parameter
              &rowTpl=`@FILE:assets/modules/yams/tpl/wayfinder/doc/row.tpl`

              to your Wayfinder snippet calls, which you’ll probably find in your document templates.

              To get a language select list or drop down select box, use
              [[YAMS? &get=`list`]]
              

              or
              [[YAMS? &get=`selectform`]]
              

              to your code. These can be customised if necessary using the YAMS snippet parameters &beforetpl, &aftertpl, &repeattpl and &aftertpl.
                YAMS: Yet Another Multilingual Solution for MODx
                YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
                Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
                • 21778
                • 223 Posts
                Thanks a lot! I did notice the tabs are working, very cool !

                I updated my languages in the config file manually, and now have the settings i need.

                One problem though, must have done something wrong hehe... wink

                When i add this to my template: [[YAMS? &get=`list`]] i get an unexpected outcome:

                (yams_choose)(yams_choose)

                * (yams-repeat:0)(yams_name)
                * (current:0)(yams_name)
                (/yams-repeat:0)
                Sorry for all the trouble PMS =)
                  • 22851
                  • 805 Posts
                  PaulSuckling Reply #8, 17 years ago
                  Just logged in and had a quick look at your site. The problem was that you didn’t associate the YAMS plugin with any of the required events (as described in the readme.txt). Done now.

                  While it is possible to edit the config file by hand, I highly recommend sorting out the permissions on the yams directory so that you can manage YAMS via the YAMS module instead. When you submit changes using the module, it not only updates your config file, but it also manages multilingual template variables etc. There is a risk that it gets out of sync if you do it by hand. (This actually happened. You had selected a multilingual template - but the template variables had not been created. Fixed now.)

                  Switching the YAMS plugin on breaks your site for the moment, so I have temporarily disabled it. You will have to enable it once you are ready. The are several reasons that it breaks your site. Firstly, for the configuration you are after you need to be using friendly URLs, but you currently have them switched off. You’ll need to a) switch them on via Tools > Configuration > Friendly URLs and b) set up a .htaccess file accordingly.

                  Once you have done that, you can re-enable the YAMS plugin. At that stage I highly recommend reading and following the Modules > YAMS > Documentation > Setup instructions step by step. You’ll notice that one of the steps will involve you having to update your .htaccess file once more according to Modules > YAMS > Server Config.

                  EDIT: By the way, you are using the very latest version of the ManagerManager plugin (0.3.4). There is an incompatibility between that version of ManagerManager and current versions of YAMS which means that your multilingual template variables are not being moved onto the language tabs in your document view. I have actually fixed that incompatibility in my development version of YAMS. I’ll release an update to YAMS which fixes the problem soon.
                    YAMS: Yet Another Multilingual Solution for MODx
                    YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
                    Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.