Hello everyone, I'm new in modx
I am evaluating the use of babel for a multilingual site (language subfolder)
I wrote a plugin to avoid modifying the .htaccess file, what do you think?
<?php
/**
* SubDirContextRoute
*
* Format url: www.example.com/??/page01.html
*
* Event: OnHandleRequest
*
**/
if($modx->context->get('key') == "mgr"){
return true;
}
$sUrl = $_GET['q'];
if(substr($sUrl,2,1)!='/'){
return true;
}
$sLang = substr($sUrl,0,2);
$oContextSetting = $modx->getObject('modContextSetting',array('key'=>'CultureKey','value'=>$sLang));
if($oContextSetting){
$sContextKey = $oContextSetting->get('context_key');
$modx->switchContext($sContextKey);
$sNewUrl=substr($sUrl,3);
$_GET['q']=$sNewUrl;
$_REQUEST['q']=$sNewUrl;
$modx->log(xPDO::LOG_LEVEL_ERROR,'[SubDirContextRoute] Trovato context della lingua: '.$sContextKey);
}
FerX - Developer at Eracom s.r.l.
-
☆ A M B ☆
- 24,524 Posts
There are a number of these, from
this one to
XRouting.
I've been using XRouting for a while now for everything from Bable to managing multiple sites from a single MODX installation.