We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45134
    • 3 Posts
    Hi everyone,

    How to make another context (not "web") set by default and website will start from it?

    Modx Revo 2.2.2, Babel installed.

    Thanks in advance!
      • 40045
      • 534 Posts
      in the modx base_path you find the index.php file, there you can change the following towards the end of the file:

      /* Initialize the default 'web' context */
      $modx->initialize('web');
      
      // to
      /* Initialize the default 'yourcontext' context */
      $modx->initialize('yourcontext');
      


      that should do it cool

      but if its a babel "problem" then you maybe just need a plugin (active OnInitCulture system even) like:

      if ( $modx->context->get('key') != 'mgr' ) {
      	/* grab the current language from the cultureKey request var */
      	$ckey = $_REQUEST['cultureKey'];
      	$host = strtolower(MODX_HTTP_HOST);
      	switch (true) {
      		case $ckey == 'de':
      			/* switch the context */
      			$modx->switchContext('web');
      			break;
      		case $ckey == 'fr':
      			/* switch the context */
      			$modx->switchContext('fr');
      			break;
      		default:
      			/* Set the default context here */
      			$modx->switchContext('defaultcontext');
      			break;
      	}
      	/* unset GET var to avoid
      	 * appending cultureKey=xy to URLs by other components */
      	unset($_GET['cultureKey']);
      }
      
      // + some .htaccess rule like
      <IfModule mod_rewrite.c>
      	# favicon redirect
      	RewriteCond %{REQUEST_FILENAME} !-d
      	RewriteCond %{REQUEST_FILENAME} !-f
      	RewriteRule ^(de|fr)/favicon.ico$ favicon.ico [L,QSA]
      
      	# assets/* redirect
      	RewriteCond %{REQUEST_FILENAME} !-d
      	RewriteCond %{REQUEST_FILENAME} !-f
      	RewriteRule ^(de|fr)/assets(.*)$ assets$2 [L,QSA]
      	 
      	# everything else redirect and setting cultureKey
      	RewriteCond %{REQUEST_FILENAME} !-f
      	RewriteCond %{REQUEST_FILENAME} !-d
      	RewriteRule ^(de|fr)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
      </IfModule>
      


      or you can try the ContextRouter plugin from the package manager [ed. note: exside last edited this post 12 years, 4 months ago.]