We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29796
    • 91 Posts
    on main domain i load one context ... now i want some other contexts to load when you enter specific URL

    i want:
    mydomain.com => default "english" context
    mydomain.com/it => show "italian" context
    mydomain.com/si => show "slovenian" context
    ...

    how can i do this? ... one way if i’m not wrong is to make that subfolders and copy index, htaccess and config file into it .. but i rather doit some other way

    i created a plugin with following code: (wich by the way doesn’t work) .. i allways getenglish context
    if($modx->context->get('key') != "mgr"){
      switch ($modx->getOption('http_host')) {
        case 'mydomain.com':
          $modx->switchContext('english');
          $modx->setOption('cultureKey', 'en');
        break;
          
        case 'mydomain.com/it':
          $modx->switchContext('italian');
          $modx->setOption('cultureKey', 'it');
        break;
    
        case 'mydomain.com/si':
          $modx->switchContext('slovenian');
          $modx->setOption('cultureKey', 'si');
        break;
      }
    }​
    


    i also updated "italian" and "slovenian" context:
    italian example:
    http_host / mydomain.com/it
    site_url / http://mydomain.com/it

    i missed something ?

    thanx for answers
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      I think http host is only the domain, and not the directory being requested.. would have to use a different var for that. (request?)
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 29796
        • 91 Posts
        yea .. i think too that http_host should be main domain ... but in first atempt it didn’t worked so i tested some other settings too ...

        anyway i read how to solve it here http://modxcms.com/forums/index.php/topic,51346.0.html

        if i’m not wrong i only have to define folders "it" and "si" in context settings site_url and base_url right? ... and of course in plugin i have to define one switch case for each folder... yes no ?