Hi elogic,
since your methods for getting estate- and staff names are supposed to
be called more than once, I would recommend to outsource your code
into model methods, so you can easily call them from your controller
and don't have any code repitition.
/*
* @param int $accountId: The Account Id to be looked for
*/
public function getEstateName ($accountId)
{
return $this->Property->User->find('first', array('conditions'
=> array('Account.id' => $accountId),
'fields' => array('Account.first_name', 'Account.last_name')));
}
Same with the staff names. You can then call it in all of your
controller functions and use the data for ... stuff.
Kind regards,
Vulinux
On 6 Jul., 06:13, elogic <[email protected]> wrote:
> Hi All,
>
> I have on my view page of properties in the controller which is
> working as I want it to.
>
> // GET THE ESTATE AND STAFF NAMES
> $estate_name = $this->Property->User->find('first', array('conditions'
> => array('Account.id' => $this->Property->field('estate_id')),
> 'fields' => array('Account.first_name', 'Account.last_name')));
> $staff_name = $this->Property->User->find('first', array('conditions'
> => array('Account.id' => $this->Property->field('staff_id')), 'fields'
> => array('Account.first_name', 'Account.last_name')));
> $this->set(compact('estate_name','staff_name'));
>
> (Call them like: <?php echo $estate_name['Account']['first_name'] . '
> ' . $estate_name['Account']['last_name']; ?>)
>
> I somehow need to get this same data on the index view within a for
> loop for each row, how would I go about this? The estate_name and
> staff_name need to be found for each record down the page.
>
> Thankyou
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php