R
R
rusiak12019-12-02 01:00:29
MODX
rusiak1, 2019-12-02 01:00:29

Context does not work in MODX Revo. Where is the mistake?

Good afternoon.
There is a site on Modx revo. It is necessary to make a variant with 2 languages.
1) Made context settings for 2 languages: English, Russian (eng, web).
Entered values: site_start, culture_key, site_url, base_url
2) Changed htaccess:
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(ru|en)?/?(. *)$ index.php?cultureKey=$1&q=$2 [L,QSA]
# redirect all requests to /de/favicon.ico and /nl/favicon.ico
# to /favicon.ico
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(ru|en)/favicon.ico$ favicon.ico [L,QSA]
# redirect all requests to /de/assets* and /nl/assets* to /assets*
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(ru|en)/assets(.*)$ assets$2 [L,QSA]
# redirect all other requests to /de/* and /nl/*
# to index.php and set the cultureKey parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ (en|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
3) And created plugin with OnHandleRequest event
<?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('en');
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']);
}
4) Installed babel and created links between several resources in a different context.
And now the problem: any time you open a resource from another context, it gives a 404 error.
Checked access rights.
In what there can be a problem and with what it can be connected?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question