Jon,
Thanks for the pointer. I had looked at containable behaviour as it
seemed to be the solution.
This was what I tried (in venues_controller.php):
debug($this->Venue->find('all', array('contain' => array('Contact' =>
array('conditions' => array('Contact.jobType' =>'main'))));
$this->set('venues', $this->paginate('Venue'));
This generates the correct data (in debug view)
but if I change to:
$venues = $this->Venue->find('all', array('contain' => array('Contact'
=> array('conditions' => array('Contact.jobType' =>'main')))));
$this->set('venues', $this->paginate('Venue'));
I get all the contacts displayed in the view.
So I guess my problem lies in the VIEW.....? I run a foreach loop:
<?php
foreach ($venue['Contact'] as $contact) :
//if ($contact['jobType'] == 'main') {
echo '<td>';
$thisContact = $contact['fName'] . ' ' . $contact['lName'];
echo $html->link($thisContact, 'mailto:'.$contact['email']);
echo ' (' . $contact['position'] . ') T: ' .$contact['telephone'] .
' E: ' . $contact['email'];
echo "</td>";
//}
endforeach; ?>
and it prints ALL the contacts for that venue, but debug is telling me
that it has only found the correct one. At this point I got confused
and so moved to looking for alternative solutions.
Any ideas?
Thanks
Eagle
On Aug 25, 12:17 am, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> > I don't know how good practice it is, but in this kind of situation, I
> > use to change temporarily the association conditions before
> > paginating, like this :
> > $this->Venue->hasMany['Contact']['conditions'] =
> > array('Contact.jobType'=>'main');
> > $this->paginate('Venue');
> > There may be more elegant solutions to do this, but ...
>
> yep, use the Containable behaviourhttp://book.cakephp.org/view/474/Containable
>
> jon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---