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: [email protected] [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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---