Thank you . Now it works fine !!
On 8/9/07, Grant Cox [EMAIL PROTECTED] wrote:
You should use recursive = 2 (0 = just the subcategory, 1 = the
category associaton, 2 = the category's language association).
You will want to access the language in your view through:
echo $filtr_lang['Subcategory']['link'];
echo $filtr_lang['Category']['kategoria'];
echo $filtr_lang['Category']['Language']['jezyk'];
as it is associated through the Category, not directly to the
Subcategory.
[EMAIL PROTECTED] wrote:
I want filter my subcategories by language_id ( this is a foreign key
in categories table and primary key in languages table). I use
recursive option ( $this-Subcategory-recursive = 3; ) in my
controller but i'm still getting this error. Which value should i
use ? 3 or 2 ?
Error in my view:
Notice: Undefined index: Language
subcategories_controller
$this-set('filtr_langs', $this-Subcategory-
findAll(array('Category.language_id' =$id)));
view:
foreach ($filtr_langs as $filtr_lang):
echo $filtr_lang['Subcategory']['id'];
echo $filtr_lang['Subcategory']['link'];
echo $filtr_lang['Category']['kategoria'];
echo $filtr_lang['Language']['jezyk'];
echo $filtr_lang['Subcategory']['podkategoria'];
php endforeach; ?
models:
--
MODEL CATEGORY
class Category extends AppModel {
var $belongsTo = array(
'Menu' = array(
'className' = 'Menu',
'foreignKey' = 'menu_id'
),
'Language' = array(
'className' = 'Language',
'foreignKey' = 'language_id'
)
);
var $hasMany = array(
'Subcategory' = array(
'className' = 'Subcategory',
'foreignKey' = 'category_id'
)
);
}
MODEL SUBCATEGORY
class Subcategory extends AppModel {
var $belongsTo = array(
'Category' = array(
'className' = 'Category',
'foreignKey' = 'category_id'
)
);
---
MODEL LANGUAGE
class Language extends AppModel {
var $hasMany = array(
'Category' = array(
'className' = 'Category',
'foreignKey' = 'language_id'
)
);
--
ANY IDEAS?
Stanley
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---