We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48345
    • 2 Posts


    Всем добрый день.
    Есть сайт на Modx revo.Нужно сделать вариант с 2-мя языками.
    Было решено воспользоваться babel.
    Что было сделано:
    1)Сделал настройку контекстов для 2-ух языков: английский, русский(eng,web).Ввел значения:site_start,culture_key,site_url,base_url
    2)Внес изменения в 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 ^(ru|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]


    3)И создал плагин с событием OnHandleRequest

    <?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)Установил babel и создал связи между несколькими ресурсами в другом контексте
    А теперь проблема: при любом открытии ресурса из другого контекста выдает 404 ошибку, даже если я открываю его из админки

    В чем может быть проблема и с чем это может быть связано??