This is basic stuff.
var $actsAs = array('Containable');
var $recursive = -1;
Ideally do this in app_model so that your whole app uses the Contain behaviour.
Your Category find is now:
$categories = $this->find(
'all',
array(
'conditions' => array('Category.category_id' => $id),
'Contain' => array(
'Post' => array(
'User' => array(
'User.id',
'User.name'
)
)
)
)
);
Jeremy Burns
Class Outfit
http://www.classoutfit.com
On 1 Nov 2011, at 20:25, Andras Kende wrote:
> Since you are showing "posts" on the view maybe it would be better to show
> that page from posts controller..
> It would be easier to get posts category users in a single query..
>
> Andras Kende
>
> On Nov 1, 2011, at 12:41 PM, Daniel wrote:
>
>> I have a categories view which shows related posts that belong to the
>> category. On the posts table there is a user_id which relates to a
>> username on the users table. I would like to display the username for
>> each post on the category view, but when I put $post['User']
>> ['username'] into the ctp file I get an error message: "undefined
>> index: User"
>>
>>
>>
>> --
>> 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
>
> --
> 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
--
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