We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21739
    • 49 Posts
    I'm getting the error below, only when accessing the root url of my website "/" (default context). When accessing /fr/* or any others for that matter, no errors occur.

    Error log:
     (ERROR @ /index.php) [OnHandleRequest]<br />
    <b>Notice</b>:  Undefined index: cultureKey in <b> ....\cache\includes\elements\modplugin\2.include.cache.php</b> on line <b>9</b>



    It seems that it's caused when the gateway plugin is executed:

    <?php
    if($modx->context->get('key') != "mgr"){
                /* grab the current langauge from the cultureKey request var */
                switch ($_REQUEST['cultureKey']) {
                    case 'en':
                        /* switch the context */
                        $modx->switchContext('english');
                        break;
                    case 'fr':
                        /* switch the context */
                        $modx->switchContext('french');
                        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']);
            }



    All context & htaccess settings should be okay. I cannot seem to figure out what's causing it, I've used this method several times without issues. Anyone?

    (Rev 2.2.7, IIS 7.5)

    Thnx!
      • 21739
      • 49 Posts
      Solved the error for now by setting a default culture key if it isn't set:
        switch (isset($_REQUEST['cultureKey']) ? $_REQUEST['cultureKey'] : 'nl') { }

      I'm still wondering however what's causing this... or is this normal behavior, which didn't give errors in previous versions of modx?
        • 38323
        • 26 Posts
        Quote from: nondotzero at Apr 17, 2013, 07:03 AM
        Solved the error for now by setting a default culture key if it isn't set:
          switch (isset($_REQUEST['cultureKey']) ? $_REQUEST['cultureKey'] : 'nl') { }

        I'm still wondering however what's causing this... or is this normal behavior, which didn't give errors in previous versions of modx?

        Thanks for this! Works, but need to change te switch to:
        switch (isset($_REQUEST['cultureKey']) or $_REQUEST['cultureKey'] = 'nl')

        otherwise the default 'nl' isn't set.