having problems with this. I have a simple "view" action, which shows
an overview of a category and related "tips". "Tips" belong to a
"Site".
I.e. Category -> Tip -> Site.
What I'm trying to do is show the site name in the table with the rest
of the data (the field is a name field). This works fine with
recursive set to 2, but I want to reduce the number of queries by
using containable, since it is overkill otherwise. I can get the FK
field to show up no problem, but the "site.name" gives this error:
Notice (8): Undefined index: name [APP\views\categories\view.ctp,
line 54]
I suspect I am not implementing the join correctly somehow. Or is it a
problem with the code in the view? I am referencing the field like
this:
$category['Site']['name'];
I have tried a few variations on the code below, including nesting
etc. would be very grateful for any assistance.
$data = $this->Category->find('first', array(
'fields' => array(
'Category.name',
'Category.description'
),
'conditions' => array(
'Category.slug' => $slug
),
'contain' => array(
'Tip' => array(
'fields' => array(
'Tip.site_id',
'Tip.id', 'Tip.name', 'Tip.description', 'Tip.created', 'Tip.expires',
'Tip.rating', 'Tip.slug'
)
),
'Site' => array(
'fields' => array(
'Site.name',
'Site.id', 'Site.slug', 'Site.category_id'
),
)
)
));
$this->set('category', $data);
If anybody has a working example of a recursive 2 replicated with
containable I would love to see it.
Thanks
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment