我做了一個TranslatableBehavior
與afterFind()
函數來修改我的輸出,它的工作原理是我想要的,但只對主要結果。當我將該模型調用爲另一個模型時,回調函數不會激活。行爲回調和包含衝突
我的結構是這樣的:
Category hasMany CategoryDynamic (dynamic table contains the translations).
Category hasMany Item
Item hasMany ItemDynamic (again, here are the item translations)
兩個Category
和Item
有可轉換行爲。當我作出以下查詢:
$current = $this->Category->find('first', array(
'conditions' => array('Category.id' => $root),
'contain' => array(
'CategoryDynamic',
'Item' => array(
'ItemDynamic'
),
),
));
它被稱爲類別,而不是項目。有沒有一種方法可以使這個工作與包含?
我想你誤解了這個問題,我不使用默認的翻譯從CakePHP的行爲,可翻譯爲我定製的行爲和問題沒有太多做的行爲做什麼。無論如何,謝謝你的努力,戴夫提供了我需要的答案。 –