I've tried your example: I added a field called "sitename" to the posts table and to some posts added the sitename value "mysite".
In routes.php in have: $Route->connect("/:sitename/posts/*", array("controller" => "posts", "action" => "index")); But when I call http://www.zomp.nl/cake_folder/mysite/posts/ I get the errors: Warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/vhosts/zomp.nl/httpdocs/framework/app/ app_model.php on line 6 Warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/vhosts/zomp.nl/httpdocs/framework/app/ app_model.php on line 6 Notice: Undefined variable: model in /var/www/vhosts/zomp.nl/httpdocs/ framework/app/app_model.php on line 6 Notice: Trying to get property of non-object in /var/www/vhosts/ zomp.nl/httpdocs/framework/app/app_model.php on line 6 To simply things, I then removed the last two conditions in the if- statements and changed $model->name to $this->name, so it reads: function beforeFind($queryData) { if ($this->hasField('sitename')) { $queryData['conditions'][$this->name . '.sitename'] = Configure::read('site'); } return $queryData; } The errors are gone now, but no posts are displayed. Does anyone know what I'm doing wrong? On 22 apr, 21:21, gerbenzomp <[EMAIL PROTECTED]> wrote: > Cool! That will save me a lot of code rewriting ;) > > Thanks for the reply, Mariano! I'm going to try it out! > > On 22 apr, 18:58, "Mariano Iglesias" <[EMAIL PROTECTED]> > wrote: > > > Sure, write sitename on your AppController::beforeFilter() to the Configure > > instance: > > > Configure::write('site', 'sitename'); > > > Then on AppModel::beforeFind() you can add a condition to set the sitename: > > > function beforeFind($queryData) { > > if ($this->hasField('sitename') && !in_array('sitename', > > array_keys($queryData['conditions'])) && !in_array($model->name . > > '.sitename', array_keys($queryData['conditions']))) { > > $queryData['conditions'][$model->name . '.sitename'] = > > Configure::read('site'); > > } > > > return $queryData; > > > } > > > -MI > > > --------------------------------------------------------------------------- > > > Remember, smart coders answer ten questions for every question they ask. > > So be smart, be cool, and share your knowledge. > > > BAKE ON! > > > blog:http://www.MarianoIglesias.com.ar > > > -----Mensaje original----- > > De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre > > de gerbenzomp > > Enviado el: Domingo, 22 de Abril de 2007 11:07 a.m. > > Para: Cake PHP > > Asunto: Routing and FindAll(); > > > But does this mean I have to add "WHERE sitename = > > $this->params[sitename];" to every findAll(), query(), etc in every > > > controller in my system? Or is there an easier way, so Cake > > automatically knows it should use the sitename in the url in every > > query? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---