Hi.....I'm doing it for languages.....

App Controller:

<?php

class AppController extends Controller
{
        var $langarr = array('en'=>'English', 'ar'=>'Arabic',
'es'=>'Espanol', 'de'=>'Deutsch', 'lt'=>'Lithuanian',
'fr'=>'Francois');
        var $components = array('Cookie', 'LanguageDetection');

        var $cookieName = 'REMEMBERMEAPPARES';
        var $cookieKey = 'dsfhjkc432saigh43';
        var $cookieDomain;

        function __construct() {
                parent::__construct();
                $host_r = explode('.', $_SERVER['SERVER_NAME']);
                if(count($host_r)>2)
                        while(count($host_r)>2) array_shift($host_r);
                $this->cookieDomain = '.'.implode('.', $host_r);
        }

        function beforeFilter()
        {
                //get the parts of the host string ( lang dot domain dot 
com/org/
edu )
                $host_r = explode('.', $this->Session->host);
                if($host_r[0]=='www')
                        array_shift($host_r);

                if(count($host_r)==3)
                {
                        $langtester = $host_r[0];
                        if(in_array($langtester, $this->langarr)) {
                                define('LANG',$langtester);
                        } else {
                                define('LANG','en');
                        }
                } else if(count($host_r)==2) {
                        $thebrowserlang = 
$this->LanguageDetection->getLangArr();

                        if(in_array($this->Cookie->read('User.lang'), 
$this->langarr))
                        {
                                
$this->redirect('http://'.$this->Cookie->read('User.lang').'.'.
$this->Session->host);
                                exit();
                        } else if(array_key_exists($thebrowserlang[1], 
$this->langarr)) {
                                
$this->redirect('http://'.$thebrowserlang[1].'.'.$this->Session-
>host);
                                exit();
                        } else {
                                
$this->redirect('http://'.LANG.'.'.$this->Session->host);
                                exit();
                        }
                }

                $this->set('all_languages', $this->langarr);
        }

}

?>

In the models that relate to a city (or a language in my case):

        function beforeFind($queryData) {
                $queryData['Interface']['lang'] = $this->lang;
                return $queryData;
        }

Ask me a question about that if you need to. You should be able to
make it work essentially the same way.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to