We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53333
    • 3 Posts
    hi!

    i got site on migxmultilang (3 languages) and question:

    how to force culture_key variable to URL on page load?

    i want URL like sitename.com/en/ - when culture_key is english

    tia

    pp
      • 46886
      • 1,154 Posts
      unfortunately I am not quite sure, did you look at the ht.access code for directing multiple languages?

      that;s what does it, the htaccess I believe
        • 53333
        • 3 Posts
        Quote from: nuan88 at Nov 18, 2018, 09:27 AM
        unfortunately I am not quite sure, did you look at the ht.access code for directing multiple languages?

        that;s what does it, the htaccess I believe

        Hmmm, in .htaccess everything is ok. Site (in PL, EN and DE) works fine but i want, for various reasons, detect culture_key and redirect from sitename.com to sitename.com/en/ when [[++cultureKey]] is english. It seems to me that I will not do it through .htaccess
          • 46886
          • 1,154 Posts
          hmm I am getting caught up between context and culture keys. They seem related.

          This site has the basics on a multi-lingual site, including a snippet to check the context and fix the culture key. It might be useful, not sure

          https://anyscreensize.com/blog/modx-multilingual/

          Here is the snippet

          	<?php
          			if($modx->context->get('key') != "mgr"){
          				/* grab the current langauge from the cultureKey request var */
          				switch ($_REQUEST['cultureKey']) {
          					case 'nl':
          						/* switch the context */
          						$modx->switchContext('Nederlands');
          						break;
          					case 'de':
          						/* switch the context */
          						$modx->switchContext('Deutsch');
          						break;
          					default:
          						/* Set the default context here */
          						$modx->switchContext('web');
          						break;
          				}
          				/* unset GET var to avoid
          				 * appending cultureKey=xy to URLs by other components */
          				unset($_GET['cultureKey']);
          			}

            • 3749
            • 24,544 Posts
            It sounds like you need to create a cultureKey Context Setting for each context other than the 'mgr' (Manager) context. Each setting's 'value' field would contain the two-letter language code for that context.

            BTW, it's definitely cultureKey, not culture_key.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting