We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29796
    • 91 Posts
    i’m building multiple sites with multiple languages, for each site variation i use one context .. i’m using following on handle request plugin:

    <?php
    $pieces = explode('/', trim($_REQUEST[$modx->getOption('request_param_alias', null, 'q')], '/'), 2);
    if (count($pieces) > 0) {
        switch ($pieces[0]) {
            case 'it':
                if (isset($pieces[1])) {
                    $_REQUEST[$modx->getOption('request_param_alias', null, 'q')] = $pieces[1];
                } else {
                    $_REQUEST[$modx->getOption('request_param_alias', null, 'q')] = '';
                }      
                switch ($modx->getOption('http_host')) {
                  case 'www.mydomain3.com': $modx->switchContext('GHK-Italian'); break;
                }
                $modx->setOption('cultureKey', 'it');
            break;
          
            default: // Default        
              switch ($_SERVER[HTTP_HOST]) {            
                case 'www.mydomain1.com': 
                  $modx->switchContext('MM-English');
                  $modx->setOption('http_host', 'www.mydomain1.com');
                  $modx->setOption('site_url', 'http://www.mydomain1.com/');
                break;
                case 'www.mydomain2.com': 
                  $modx->switchContext('MM-English'); 
                  $modx->setOption('http_host', 'www.mydomain2.com');
                  $modx->setOption('site_url', 'http://www.mydomain2.com/');
                break;
                case 'www.mydomain3.com': $modx->switchContext('GHK-English'); break;
                case 'www.mydomain4.com': $modx->switchContext('GCM-English'); break;
                case 'www.mydomain5.comm': $modx->switchContext('ABH-English'); break;            
                default: $modx->switchContext('ABH-English'); break;
              }
              $modx->setOption('cultureKey', 'en');
          break;
      }
    }?​


    first i had few domains in eng lang .. each domain pointed to one context .. all worked fine now i have two problems

    1. domain1 and domain2 .. both need to show the same context (MM-English) .. anyway .. they do, but the link are not working properly ..on domain2 all links points to domain1. In context settings i defined base_url, site_url, ... but is for one domain only .. i need different option for seccond domain
    ... i tryed to use $modx->setOption to change base url and site url but no success ..i could create a snippet to get right url but i used all over the site [[++site_url]] so i want to change that if it’s possible ??

    2. seccond problem is with multilanguage .. www.mydomain3.com shows english site .. www.mydomain3.com/it/ must show italian site ... well it works fine .. but path to css files and other elements is corupted by /it/ ... ok i could use a snippet with output like $output = ’http://’.$_SERVER[HTTP_HOST].’/’; .... what is the proper way to handle this?

    i had similar problems with another site because of two domains pointed at one context... the cache was created for domain i entered first ... on seccond domain all internal links pointed to first domain .. if i cleared the cache and went to seccond domain .. all internal links on first domain pointed to seccond one ... cache mess ..

    i know that two domains for one page is not good for SEO but this doesn’t matter in my case
      • 21838
      • 284 Posts
      No replies? It would be interesting for me, too…
        MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
        • 33976 ☆ A M B ☆
        • 571 Posts
        Hi,

        Wouldn’t a
        <base href="[[!++site_url]]" />
        in your template solve the problem ?
          • 21838
          • 284 Posts
            MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)