Subscribe: RSS
  • Hello,
    I'm currently setting up a modx multilingual with modx.

    Everything is working fine except that a specific context like /fr/ keep linking to all / resources.

    Exemple
    http://aikidomontreux.com/fr/horizontal-menu/aikido/

    click on aikido and you will be redirected to
    http://aikidomontreux.com/horizontal-menu/aikido/

    instead of :
    http://aikidomontreux.com/fr/horizontal-menu/aikido/

    Here is my config :
    modx : MODX Revolution 2.2.6-pl (traditional)
    babel 2.2.5

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


    .htaccess :
    RewriteEngine On
    RewriteBase /
    
    
    
    # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^aikidomontreux\.com [NC]
    RewriteRule (.*) http://aikidomontreux.com/$1 [R=301,L]
    #
    # or for the opposite domain.com -> www.domain.com use the following
    # DO NOT USE BOTH
    #
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} !^www\.example-domain-please-change\.com [NC]
    #RewriteRule (.*) http://www.example-domain-please-change.com/$1 [R=301,L]
    
    
    
    # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
    # https://www.domain.com when your cert only allows https://secure.domain.com
    #RewriteCond %{SERVER_PORT} !^443
    #RewriteRule (.*) https://example-domain-please-change.com/$1 [R=301,L]
    
    
    
    
    
    # redirect all requests to /de/favicon.ico and /fr/favicon.ico
    # to /favicon.ico
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(en|fr|de)/favicon.ico$ favicon.ico [L,QSA]
    
    # redirect all requests to /de/assets* and /fr/assets* to /assets*
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(en|fr|de)/assets(.*)$ assets$2 [L,QSA]
    
    # redirect all other requests to /de/* and /fr/*
    # to index.php and set the cultureKey parameter
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(en|fr|de)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]


    contexts :
    web
    base url : /
    culture key : en
    site url : http://aikidomontreux.com/
    fr
    base url : /fr/
    culture key : fr
    site url : http://aikidomontreux.com/fr/
    de
    base url : /de/
    culture key : de
    site url : http://aikidomontreux.com/de/
    • Hi mojomateo,

      first: did you check, if the gateway-plugin has the system event "OnHandleRequest" is activated?

      And it seems to me, that your problem is not linked to babel but to the way you generate your menu.
      Do you use the wayfinder plugin?
      if so, do you use something like:
      [[!Wayfinder? 
        &level=`1` 
        &startId=`[[BabelTranslation? &resourceId=`xy` &contextKey=`[[*context_key]]` &showUnpublished=`1`]]` ]]
      ?

      best
      fabian
      • Thank you Fabian,
        I'll try that as soon as possible
        • first: did you check, if the gateway-plugin has the system event "OnHandleRequest" is activated?
          yes

          And it seems to me, that your problem is not linked to babel but to the way you generate your menu.
          I'm using getResources :

          [[!getResources? &parents=`6` &tpl=`verticalMenu` &tplFirst=`verticalMenuFirst` &tplLast=`verticalMenuLast` &limit=`100`  &depth=`0` &sortby=`{"menuindex":"ASC"}`]]


          Are you sure you have to specifically set every link with the context ?
          Isn't it automatic with the gateway plugin?

          ( I have tested the context are switching correctly with /fr/ and /de/ links [ed. note: mojomateo last edited this post 2 years, 9 months ago.]
          • Hi Mojomateo, did you solve this issue yet? I have the same right now and I can't solve it. [ed. note: gallenkamp last edited this post 1 month, 3 weeks ago.]
            • I found the solution for me. I had to extend the base URL in my header template:

              <head>
                  <base href="https://whew100.de[[++base_url]]" />
                  <title>[[*pagetitle]] - [[++site_name]]</title>


              I added [[++base_url]] which is what I set in the context settings before.