We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16545
    • 358 Posts
    Hello everybody,
    I’ve got a simple situation, then I’ve got a simple languages links from chunk {{langs}}
    <a href="(yams_server)">en</a> <a href="(yams_server)de">DE</a> <a href="(yams_server)fr">FR</a> 


    But I need .active class to eliminate selected language.

    Question: what is the simplest and the right solution for this task?


    Thx.
      • 22851
      • 805 Posts
      Use
      [[YAMS? &get=`list`]]
      to generate a language list.

      The generated list can be customised using the YAMS snippet parameters [tt]&beforetpl[/tt], [tt]&aftertpl[/tt], [tt]&repeattpl[/tt] and [tt]&currenttpl[/tt] to set templates for the start of the list, end of the list, the list item and the list item for the current (active language). If you don’t want the current language to appear in the list at all you can set [tt]&currenttpl=``[/tt]. You might also want to set [tt]&beforetpl=`@code:<ul>`[/tt] to remove the ’select a language’ text that is output by default at the start of the language list.

      Take a look at the documentation for generating a language flag list for a similar example, or look in [tt]assets/modules/yams/tpl/yams/list/[/tt] to see the default templates loaded by the [tt]&get=`list`[/tt] parameter so that you can copy and customise them.
        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.
        • 16545
        • 358 Posts
        Thx a lot, I thought that it could be easier to do the same things...
        Anyway, it works:)
          • 16545
          • 358 Posts
          Almost fine, but two things are out of control.
          1) It’s a language list sorting:

          I’ve got these languages in YAMS module (from left to right) - en | de (default)| fr
          and my chunk {{langs}}
          with
          [[YAMS? &get=`list` &beforetpl=`@code:<ul>` &repeattpl=`lang_link` &aftertpl=`@code:<ul>` &currenttpl=`lang_current`]]

          has this output ->
          <li class="lang><a href="http://www.domain.tld/fr/doc.html" lang="fr" dir="ltr" title="France">fr</a></li>
          <li class="lang active" title="German">de</li>
          <li class="lang"><a href="http://www.domain.tld/en/doc.html" lang="en" dir="ltr" title="English">en</a></li>


          Problem: I must have another langs ordering - de | en | fr

          2) There is no output of these tags - <ul></ul>
            • 22851
            • 805 Posts
            Language Order
            The languages are output in the order that they appear in the YAMS Module "Language Settings" tab.

            It is possible to change the order of the languages via the YAMS module interface, but since I haven’t built anything into YAMS specifically to help you do this easily (an oversight!), it involves playing a little game with deactivating and reactivating languages: If you deactivate and reactivate a non-default language it gets placed last in the list. To change the position of the default language you first have to switch the default to a different language, then deactivate and reactivate it, and then switch it back. This should provide enough flexibility for you to be able to organise the languages as you wish.

            An alternative approach which is probably far simpler in this case is to edit the YAMS config file directly ([tt]assets/modules/yams/yams.config.inc.php[/tt]). I don’t normally recommend editing it, because you can quite easily break YAMS by doing so, but in this case it should be okay. At the top of the file you should see something like
              // The ids of the active languages
              $this->itsActiveLangIds = array(
                'fr'
                , 'de'
                , 'en'
              );
            

            You just need to change the order of the language ids in this array:
              // The ids of the active languages
              $this->itsActiveLangIds = array(
                'de'
                , 'en'
                , 'fr'
              );
            


            Missing list start and end
            My mistake. The [tt]@CODE[/tt] needs to be written in upper-case, not in lower case as in my earlier post. (Also note that your closing tag is not closed. Needs to be [tt]</ul>[/tt] not [tt]<ul>[/tt].)
              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.
              • 16545
              • 358 Posts
              Great!!! Now it’s perfect, thx a lot for supporting.

              P.S. Fix documentation http://svn.modxcms.com/docs/display/ADDON/YAMS+Language+Flag+List
              @code to @CODE
                • 22851
                • 805 Posts
                Quote from: labasus at Jul 05, 2010, 03:02 PM

                P.S. Fix documentation http://svn.modxcms.com/docs/display/ADDON/YAMS+Language+Flag+List
                @code to @CODE
                Done. Thanks!
                  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.