We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10313
    • 375 Posts
    Hello,

    I’m creating a multilingual website. First lang is German, second (current) is english, more to follow.

    I’m using several chunks, e.g. for ditto. In these chunks I sometimes have "fix" phrases like "read more" that should be output in the appropriate language. So I created chunks like "lbl_readmore_de" and "lbl_readmore_en". I store the language via TV in the document as "de" and "en". Now, I want to create the needed chunk name by adding the TV value to the fix beginning:

    {{lbl_readmore_[*language*]}}

    This should become {{lbl_readmore_de}} or whatever language is the current one.

    How can I get this working within a chunk? I already tried it, but it doesn’t work. Even PHx won’t help if I can’t access the TV from within the chunk.

    Any ideas are very welcome smiley
    Thanks
    Martin
      • 20413
      • 2,877 Posts
      You should be able to call the tv within a chunk? No? //...you meant chunk placeholder!

      Check out this plugin ---> http://modxcms.com/forums/index.php/topic,32807.0.html
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 10313
        • 375 Posts
        What I need within my chunk: generate the name of a different chunk by adding the TV value after the prefix of a chunk name:

        in my Ditto Template chunk:
        ...
        <a href="[~id~]">{{lbl_readmore_[*language*]}}</a>
        ...
        


        to output the link "read more" ore "mehr" or whatever in the given language.

        The Plugin you suggested is quite cool, but the author follows a completely different way than me, and additionally:
        EasyLingual ONLY converts [% %] tags in Templates, Page content and page Introtext. NOT in TVs and CHUNKs!

        So it won’t work in my case. I actually want to avoid to duplicate my ditto templates for each language.

        Martin
          • 20413
          • 2,877 Posts
          How do you get the [*tv to switch*]

          Could you not use

          [*lbl_readmore*]
          And have it switch chunks
          {{language_one}}||{{language_two}}

          //Bruno rocks!!
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 4172
            • 5,888 Posts
            You can try this snippet:
            <?php
            //[!getLangChunk? &ChunkName=`lbl_readmore_` &lang=`[*language*]`!]
            return '{{' . $ChunkName . $lang . '}}';
            ?>
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 10313
              • 375 Posts
              Calling a snippet with the [*language*] TV does work!!!

              Thank you very much. I wonder why I need this workaround and can’t use my first approach. Probably it’s the processing order of TVs, chunks, snippets and all of that.

              Thank you again
              Martin