Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // if we are in context www-en…
- if ($modx->context->get('key') == "www-en") {
- $o = '';
- // …grab www-fr infos
- $modx->switchContext('www-fr');
- $ss = $modx->getOption('site_start');
- $ctx = $modx->context->get('key');
- // grab datas from TV named multi (containing ID of the translated resource)
- $tvv = $modx->resource->getTVValue('multi');
- // if there is no translation (empty TV), return the start_start ID
- if (empty($tvv)) {
- $o = $ss;
- } else {
- $o = $tvv;
- }
- $u = $modx->makeUrl($o,$ctx,'','full');
- // going back to original context
- $modx->switchContext('www-en');
- return $u;
- }
- // else if we are in context www-fr…
- else if ($modx->context->get('key') == "www-fr") {
- // …grab www-en infos
- $modx->switchContext('www-en');
- $ss = $modx->getOption('site_start');
- $ctx = $modx->context->get('key');
- $tvv = $modx->resource->getTVValue('multi');
- if (empty($tvv)) {
- $o = $ss;
- } else {
- $o = $tvv;
- }
- $u = $modx->makeUrl($o,$ctx,'','full');
- // going back to original context
- $modx->switchContext('www-fr');
- return $u;
- }
- // we are somewhere else…
- else {
- // …return an error (enhance later for > 2 lang)
- return '#error';
- }
Add Comment
Please, Sign In to add comment