<![CDATA[ Modx babel, all links link to the default context and not the relative one - My Forums]]> https://forums.modx.com/thread/?thread=96240 <![CDATA[Modx babel, all links link to the default context and not the relative one]]> https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520717 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/]]>
mojomateo Feb 16, 2015, 10:27 AM https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520717
<![CDATA[Re: Modx babel, all links link to the default context and not the relative one]]> https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-554731
<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.]]>
gallenkamp Oct 23, 2017, 05:01 PM https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-554731
<![CDATA[Re: Modx babel, all links link to the default context and not the relative one]]> https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-554729 gallenkamp Oct 23, 2017, 04:30 PM https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-554729 <![CDATA[Re: Modx babel, all links link to the default context and not the relative one]]> https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520978 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]]>
mojomateo Feb 19, 2015, 04:03 PM https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520978
<![CDATA[Re: Modx babel, all links link to the default context and not the relative one]]> https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520884 I'll try that as soon as possible]]> mojomateo Feb 18, 2015, 05:58 PM https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520884 <![CDATA[Re: Modx babel, all links link to the default context and not the relative one]]> https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520775
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]]>
achterbahn Feb 17, 2015, 06:15 AM https://forums.modx.com/thread/96240/modx-babel-all-links-link-to-the-default-context-and-not-the-relative-one#dis-post-520775