<![CDATA[ site_start setting not being affected by context settings - My Forums]]> https://forums.modx.com/thread/?thread=104897 <![CDATA[site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564042
From everything I've read, the context settings should be overriding the system setting - I've tried with a few other settings, and those are working properly (it shows the context setting if it's defined, not the system one), but site_start is keeping its value from the System Settings instead. I've also checked the User settings and those are totally blank, so it's not getting set there. Is there something that I've missed that has a higher priority, or might be changing the setting back somehow?

Thanks very much!]]>
joshkalsi Feb 11, 2019, 04:39 PM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564042
<![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564094 joshkalsi Feb 15, 2019, 09:16 AM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564094 <![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564089
The friendly URLs part of the standard MODX .htaccess file redirects everything to the index.php file in the MODX root directory. If requests are being redirecting to yoursite.com/fr/index.php, that won't be found which will bounce the user back to that same rule in an infinite loop -- hence the timeout.

Unfortunately, I don't know anything about either Babel or LangRouter, so I can't say why this is happening, but if either one alters or gives advice about altering .htaccess, I'd take another look at that process.

]]>
BobRay Feb 14, 2019, 08:33 PM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564089
<![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564079
Yep, Babel is installed and does seem to be working properly, I've got no issues with the translated pages themselves, it's just this weird homepage thing. I'll have a look into that, anything in particular I should be looking for that might be causing issues?]]>
joshkalsi Feb 14, 2019, 09:53 AM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564079
<![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564077

Assuming that users are logging in, it might help to add this to the login tag:

&contexts=`en,fr,nl`


I see LangRouter is meant to be used with Babel. You have that installed and configured, right?

At this point, I'd suspect a problem with your .htaccess file.]]>
BobRay Feb 14, 2019, 04:17 AM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564077
<![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564074 still showing the System value of the French ID. Not only are the Context settings not being applied, neither are the User ones, so this is obviously a bit deeper than I thought!]]> joshkalsi Feb 13, 2019, 04:32 PM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564074 <![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564073
        if ($this->modx->context->get('key') != "mgr" && MODX_API_MODE == false) {
            $this->langrouter->logRequest('Unhandled request');

            // Get contexts and their cultureKeys
            $contextmap = $this->modx->cacheManager->get($this->langrouter->getOption('cacheKey'), $this->langrouter->getOption('cacheOptions'));
            if (empty($contextmap)) {
                $babelContexts = explode(',', $this->modx->getOption('langrouter.contextKeys', null, $this->modx->getOption('babel.contextKeys'), true));
                $contextmap = $this->langrouter->contextmap($babelContexts);
                $this->modx->cacheManager->set($this->langrouter->getOption('cacheKey'), $contextmap, 0, $this->langrouter->getOption('cacheOptions'));
            }
            $this->langrouter->logDump($contextmap, 'contextmap');

            // Determine language from request
            $queryKey = $this->modx->getOption('request_param_alias', null, 'q');
            $query = (isset($_REQUEST[$queryKey])) ? $_REQUEST[$queryKey] : '';

            $cultureKey = (strpos($query, '/') !== false) ? substr($query, 0, strpos($query, '/')) : $query;

            if ($cultureKey || $query === '') {
                // Serve the proper context and language
                if (array_key_exists(strtolower($cultureKey), array_change_key_case($contextmap))) {
                    $contextKey = $this->modx->context->get('key');
                    if ($contextKey != $contextmap[$cultureKey]) {
                        $this->modx->switchContext($contextmap[$cultureKey]);
						$this->modx->reloadContext($contextmap[$cultureKey]);
                    }

                    // Remove cultureKey from request
                    $_REQUEST[$queryKey] = preg_replace('~^' . preg_quote($cultureKey, '~') . '/(.*)~', '$1', $_REQUEST[$queryKey]);
                    $_SERVER['REQUEST_URI'] = preg_replace('~^/' . preg_quote($cultureKey, '~') . '/(.*)~', '/$1', $_SERVER['REQUEST_URI']);

                    $this->langrouter->logRequest('Culture key found in URI');
                    $this->modx->cultureKey = $cultureKey;
                }


The log function on line 2 outputs this, which shows the context as web and the site_start as 1, which I'd expect (note I've added the "from context" string to the log function, just so I can verify where the setting is coming from).

[2019-02-13 15:41:25] (ERROR in LangRouter @ /paas/c0068/www/core/components/langrouter/model/langrouter/langrouter.class.php : 155) Unhandled request:
REQUEST_URI:   /nl/index
REDIRECT_URI:  
QUERY_STRING:  q=nl/index
q:             nl/index
Context:       web
Site start:    1 - from context


Then, the context gets switched on line 24 based on the URL - I've added the reloadContext call too as you suggested, doesn't seem to be making a difference alas, as when the log is called again on line 32 it outputs:

[2019-02-13 15:41:25] (ERROR in LangRouter @ /paas/c0068/www/core/components/langrouter/model/langrouter/langrouter.class.php : 155) Culture key found in URI:
REQUEST_URI:   /index
REDIRECT_URI:  
QUERY_STRING:  q=nl/index
q:             index
Context:       nl
Site start:    1 - from context


The context has been changed correctly, but the site_start is still 1, and it's definitely coming from the context.

I've also tried changing the log to check other context settings and those are coming out correct, it's just something weird happening with this site_start for some reason. I think I'm gonna take this to the LangRouter people and see if they can help cause I am still stumped - thanks for the assistance so far though! Figured I'd throw all this up in case it helps someone else down the line.

]]>
joshkalsi Feb 13, 2019, 04:14 PM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564073
<![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564057
Try manually deleting the core/cache files to make sure your changes apply.

Another possibility is that your multi-language system is switching to the alternate context after the settings have already been loaded. index.php initializes the 'web' context by default which loads all its settings. The switchContext() method likely gets called somewhere, which should redo the settings, but maybe reloadContext($ctx) is also necessary.

Are you running any extra cache system like Varnish, Memcache, or APC? That could also be the problem.

Also, try your browser in private of incognito mode to see if it might be a browser cache issue.

]]>
BobRay Feb 12, 2019, 07:17 PM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564057
<![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564048 joshkalsi Feb 12, 2019, 09:33 AM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564048 <![CDATA[Re: site_start setting not being affected by context settings]]> https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564044
<base href="[[!++site_url]]" />


Without that, you'll often get a cached version from a different context.

]]>
BobRay Feb 11, 2019, 08:37 PM https://forums.modx.com/thread/104897/site-start-setting-not-being-affected-by-context-settings#dis-post-564044