It should work with Containable behavior.

for example

$categories = $this->Category->find('all', array('contain' =>
array('Item' => array('Label'))));

should return an array like:

Category 1
     Item 1
          Label 1
     Item 2
          Label 2
Category 2
    Item 3
          Label 3

On Jun 7, 10:17 pm, bmcelhany <bmcelh...@gmail.com> wrote:
> Hi all,
>
> I've been working on this for a while and searching for a solution,
> but can't seem to get it working correctly. Let's say I have Category,
> Label, and Item models with the following associations:
>
> Category hasMany Items
> Item belongsTo Category
> Label hasMany Items
> Item belongsTo Label
>
> So, Categories and Labels are completely unrelated, but the Item
> belongs to both of them. Now, in my Category view (and Category
> controller) I want to display the Cateogry info (obviously) and a list
> of all of that Category's Items. So far so good. However, what I'd
> also like is, for each Item that is listed, to display that Item's
> associated Label. Something like:
>
> Category 1
>      Item 1 (Label for Item 1)
>      Item 2 (Label for Item 2)
> Category 2
>      Item 3 (Label for Item 3)
>
> I've tried different combinations of recursion (on all three models)
> and I've tried using the containable behavior but I can't seem to get
> the Label data to be included. The label data appears fine when I'm
> working with the Item views and controller, but when I'm up one level
> higher (in the context of a Category) they aren't attached.
>
> Any thoughts on this? Thanks!

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to