We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2901
    • 277 Posts
    Hi All
    I am working on a big site using extensive ditto config files, but somehow the &language parameter is not supported, is there a special way to add it? That would really help a lot having the language parameter in the config files as well.

    Thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The config files are ordinary PHP files, so it needs to be $variablename instead of &variablename.

        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 2901
        • 277 Posts
        Hi Susan

        I did it with the $variable name it still does not work.
          • 22668
          • 718 Posts
          Yep. It doesn’t work for me too.
            • 2901
            • 277 Posts
            anyone a idea how to fix this? this would really help making things a lot easier.
            this happens in version Evo 1.0 RC 1.00, but I don’t think it has to do with the version anyway.

            Thanks in advance.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              The way Ditto determines what files to include makes this impossible. The language needs to be specified in the snippet call (or in the snippet configuration, if it’s going to be site-wide)
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 16278
                • 928 Posts
                "In our country, everything is possible", as the Russians say.
                The problem is that the language file and the config file are read in the same loop (in lines 197-198 of the snippet code). For the language to become part of the $files array that lists files to include, the config file would need to have been read in prior to this.

                A quick fix: you can create your own language parameter in your config file, let us call it $c_language, and test for its existence after the file-inclusion loop. If it exists, you can use it to include the relevant language file. This then sets $_lang, which is the deciding factor in all the language settings that follow.

                Insert the following after the foreach loop in lines 194-206 of the snippet code (foreach ($files as $filename => $filevalue) { ... } ) and before line 208 (//---Initiate Class---------)
                if (isset($c_language)) {
                   include $ditto_base."lang/$c_language.inc.php";
                }

                In your config file, set $c_language as required, e.g. :
                $c_language = 'german'; 

                Obviously this could do with a little bullet-proofing, but it worked for me testing with ’german’ and ’francais’ as values and seeing what [+next+] and [+previous+] produced with pagination set.
                smiley KP
                  • 2901
                  • 277 Posts
                  @kp52
                  thanks a lot for that. I will sure try it.

                  cheers
                  Beat
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    I think the logic in the way it’s done is that you can have exactly the same snippet calls, using exactly the same config file, except for the language. Why have four different config files if the only difference is going to be the language? It would make more sense in that case to have the language setting in the snippet call.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org