Actually I made a mistake, so I'm correcting me first:
In you Model you need to call $this->find instead of 
$this->Property->User->find of course.

Model- and Controller Method should never ever be called from the View. The 
Model got all the methods for retrieving and manipulation of an object, 
while the controller organizes or prepares the data, that is rendered in the 
View or Saved in the Model. See: 
http://book.cakephp.org/view/890/Understanding-Model-View-Controller
So you create either a Model Method for your find and call it in the 
controller or you call the find directly in the controller. If a custom find 
is not reused in your application I always call the find with all its 
parameters instead of creating a whole method for this.

In your case, you call either the model method, or the find and store its 
return into a variable. Then you call the ControllerMethod for populating 
the variable to the view 
(http://api13.cakephp.org/class/controller#method-Controllerset). In your 
view, you then just run through that variable using a foreach/for.

Example:

*Model*

Class User extends AppModel 
{

public function findUserByAccountId ($accountId) {
return $this->find(blablabla);
}
}

*Controller

*Class UserController extends AppController
{

public function populateUsersByAccountId ($accountId)
{
// You can do it this way:
$this->set('users', $this->User->findUserByAccountId($accountId));

// or to increase readability for other developers
$users = $this->User->findUserByAccountId($accountId)
$this->set('users', $users);
}
}

*View*

<?php foreach ($users as $user) : ?>

// Do something with $user

<?php endforeach; ?>


Hope it helps.

Kind regards,
Vulinux

-- 
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

Reply via email to