We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40762
    • 54 Posts
    Hello everybody again,

    This week I have created a countryrenderer for MIGX based on key. I am using the country list in the lexicon. This component becomes particularly useful when developing multilingual website. My code is still a little bit glitchy though.

    The moment I have more than one element in the grid the countries dont show up.

    I am sure you guys could help me improve the code has I dont know extjs.

    $_country_lang = array();
    include $this->modx->getOption('core_path').'lexicon/country/en.inc.php';
    
    
    $countrylist=json_encode($_country_lang);
    
    $renderer['this.renderCountry'] = "
        renderCountry : function(val, md, rec, row, col, s){
    
         var countryJson='{$countrylist}';
      
         //Stripping the JSON message
         countryJson=countryJson.replace('{','');
         countryJson=countryJson.replace('}','');
         countryJson=countryJson.replace(/\"/gi,'');
    
         var countryArray =countryJson.split(',');
    
         
        
         for(var country=0; i<countryArray.length; i++){
    
            var countryObj=countryArray[i].split(':');
    
           if(countryObj[0]==val){
             
             
     
             return(countryObj[1]);
            }
    
    }
    
    
    		return '';
    	}
    ";


    Thanks
      Marc-Andre Audet
      • 4172
      • 5,888 Posts
      you can also use the renderChunk - renderer , create a snippet to get the country and place that snippet-call into the renderChunk - chunk.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40762
        • 54 Posts
        I think I am starting to understand the situation with my problems...

        it seems like modx is sending me notices of undefined var (probably because of my poor programing) and extjs does not like those notice and it blocks some process to be completed.

        I turned off debug mode and everything works great!
          Marc-Andre Audet