@Andrel: I'd love to be able to set the conditions in the model, but
the model can't know what's in the session!
@Paul:
> > $this->Person->contain('Hobby', 'Job');
>
> I've never seen anyone set containable options like above, I thought
> they had to be within the find options array
http://book.cakephp.org/view/857/Containing-deeper-associations
> I don't see how your conditions array can be set the same for every
> model within your schema as I doubt every model is directly associated
> to People for the conditions People.schedule_id to work.
Every model is related to the Schedule model. So I was thinking of
something like this in the appController:
$this->{$model}->conditions->array('schedule_id' => $schedule_id);
but i don't think that will work...
Also, every related model has to be given those conditions in the
containable:
$this->[$model}->contain(
"{$related_model1}.schedule_id = $schedule_id",
"{$related_model2}.schedule_id = $schedule_id"
);
> And what about the finds where a user is not logged in/has not created
> a session, they can't have a schedule_id set?
No user has to be logged in. I am doing this in the appController:
function beforeFilter() {
// put the latest published schedule into the session
if (!$this->Session->check('Schedule')) {
$schedule = ClassRegistry::init('Schedule')->find('first',
array('order' => 'id desc')
);
$this->Session->write('Schedule', $schedule['Schedule']);
}
}
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" 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