We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52064
    • 120 Posts
    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.
      • 28042 ☆ 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.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org