We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12508
    • 63 Posts
    I'm working on a multi-language website using MODx and Babel. On the start page, I have a getResources call to a specific document ID which brings only the "leading" language (the language on the primary context) but does not change the language when the user switch to another language. Is it possible to tell getResources call to use the "current" language when the user switches?

    Here the getResources Call:
    [[!getResources?	
    	&parents=`52`
    	&includeContent=`1`
    	&includeTVs=`1`
    	&processTVs=`1`
    	&depth=`1`
    	&tpl=`tpl-Service`
    ]]
    

    And here the template (tpl-Service):
    <article class="ym-g33 ym-gl">
        <div class="ym-gbox">
            <a class="service" href="[[~[[+content]]]]">
                <div class="icon-background" id="[[+tv.ID]]">
                    [[+tv.icon]]
                </div>
                <h3>[[+pagetitle]]</h3>
            </a>
        </div>
    </article>
    

    I really appreciate any help.

    . . . . .

    MODX Revolution 2.2.5-pl (traditional)
    PHP Version 5.3.5
    Database type: mysql
    Database version: 5.5.9
    Database charset: utf8
    Mac OS X 10.8.2
    MAMP Pro V. 1.9.6.1

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      One way would be to create context settings for the parent value. Have the resource ID for the appropriate parent as the value for the setting in each context, then use [[++parent]] for your &parents parameter value.

      http://rtfm.modx.com/display/revolution20/Contexts
        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
        • 36722
        • 101 Posts
        Yeah, look into the BabelTranslation snippet . http://rtfm.modx.com/display/ADDON/Babel.BabelTranslation

        Actually upon trying to understand your issue more I think I know the problem, and it's been solved smiley.

        Here is what we did on a site using getresourcesfield . We used a snippet called getContext ... no idea where it came from to be honest... must have scraped it from some where, but google turned up nothing for me.

        [[getResourceField? 
        	&id=`[[getContext:isequalto=`web`:then=`46`:else=`172`]]`
        	&field=`pagetitle`
        	]]


        So here is the getContext snippet.

        <?php
        $contextKey = $modx->context->key;
        
        return $contextKey;


        Enjoy, use responsibly.
          Shawn Himmelberger
          Himmelberger Design
          https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Design | https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Development
          • 12508
          • 63 Posts
          Quote from: sottwell at Dec 21, 2012, 07:36 PM
          One way would be to create context settings for the parent value. Have the resource ID for the appropriate parent as the value for the setting in each context, then use [[++parent]] for your &parents parameter value.

          http://rtfm.modx.com/display/revolution20/Contexts

          Thank you Sottwell, it worked!
            • 12508
            • 63 Posts
            Thank you himmdesign for your help. Although at this moment I'm not using your plugin, surely I will save it for future solutions.
              • 50923
              • 137 Posts
              Quote from: himmdesign at Dec 21, 2012, 07:48 PM
              Yeah, look into the BabelTranslation snippet .
              [[getResourceField? 
              	&id=`[[getContext:isequalto=`web`:then=`46`:else=`172`]]`
              	&field=`pagetitle`
              	]]


              Nice txnaks mate, but what if I have three context, like web ,English, Polish?
                <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
                • 50606
                • 1 Posts
                [[!BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`__`]]