We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19302
    • 6 Posts
    Ok, I still need help with this - I may have posted in the wrong forum / or my post might have been previously unclear - will try again. It was here ( http://modxcms.com/forums/index.php/topic,65789.0.html ).

    Have just upgraded from 2.1.1 and it’s still not working as expected. But, just this morning I made progress, so perhaps this might make the situation clearer.

    I’ve got a site setup with three contexts - plus one for the default web context. I have 3 domains (these are aliases) going to three contexts - nothing is going to the default web context.

    EG :

    domain.com -> com context
    domain.com.au -> au context
    domain.co.nz -> nz context

    Nothing goes to the default web context - we’re using that for documents / and page-not-found documents shared across the three domains (which does work quite well).

    If I use the plugin from the wiki :

    switch ($modx->getOption('http_host')) {
       case 'domain.com':
          $modx->switchContext('com');
          break;
       case 'domain.co.nz':
          $modx->switchContext('nz');
          break;
       case 'domain.com.au':
          $modx->switchContext('au');
          break;
       default:
          break;
    }
    


    The front end displays perfectly. But if I login to the manager @ domain.com/manager (it fires the switchContext) and the manager gives me "Access Denied". The same for the other two domains. At this stage I’m effectively locked out of the manager - so have to go to the db and disable the plugin. Then we’re back in business.

    So, I disabled the plugin - and edited the index.php to :

    switch ($_SERVER["HTTP_HOST"]) {
       case 'domain.com':
          $modx->initialize('com');
          break;
       case 'domain.co.nz':
          $modx->initialize('nz');
          break;
       case 'domain.com.au':
          $modx->initialize('au');
          break;
       default:
          $modx->initialize('web');
          break;
    }
    


    And now both the manager and front-end work as expected. It doesn’t seem like you can use the manager when a ’switchContext’ has been fired... and obviously updating the index.php isn’t a very good solution. I’m sure that there’s something wrong... ? lol, help?
      • 33976 ☆ A M B ☆
      • 571 Posts
      Hi,

      Ain’t got any solution for that problem sorry, but i wanted to thank you about exposing your problem… i was getting an access denied message after a 2.1.2 upgrade and your message helped me to understand the plugin was the problem smiley
        • 3749
        • 24,544 Posts
        You might try adding something like this to the top of the plugin:

        if ($modx->context->get('key') == 'mgr') {
        
            return;
        
        }


        If that doesn’t work, maybe you can use this:


        if (str_str($_SERVER['REQUEST_URI'],'manager')) {
             return;
        }
          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
          • 22303 MODX Staff
          • 10,725 Posts
          What event are you using for the plugin? It should definitely not be firing on the mgr Context.
            • 19302
            • 6 Posts
            Hey,

            Thanks all for your replies - makes sense that it shouldn’t be firing on the mgr context.

            At the moment it’s firing on ’onHandleRequest’ - and I’ve used the instructions from : http://rtfm.modx.com/display/revolution20/Using+One+Gateway+Plugin+to+Manage+Multiple+Domains

            Bob - your code :

            if ($modx->context->get('key') == 'mgr') {
                return;
            }
            


            At the beginning of the plugin works perfectly, so thanks. If it’s an issue on the wiki - would someone be able to update it? And thanks to you chaps for helping.
              • 3749
              • 24,544 Posts
              Quote from: michaelm at Jul 11, 2011, 04:30 PM


              if ($modx->context->get('key') == 'mgr') {
                  return;
              }
              


              At the beginning of the plugin works perfectly, so thanks. If it’s an issue on the wiki - would someone be able to update it? And thanks to you chaps for helping.

              Done. Thanks for providing the link. smiley
                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