Tuesday, October 16, 2012

CakePHP 1.3 Multiple Model Trees with translations getting errors

I am using one database table for storing all the data of the site. Every model saves its records in this table and every model has Tree and Translate behavior. Every record has a `type` row where the model name is stored.
So when saving data for each model it also saves a record in the i18n table with the translation.
Now when I try any action with the tree I get an error, for example:
- if I try to verify the tree I get errors for all the records which parents are not from the same model due to the Translate behavior
- if I move some record up and down in one model it moves between all other record from the other models along the tree, so sometimes if the parent record has 10 records from a different model I will have to move up (for example) 10 times without no visual effect
- the same scenario as the last one but if I add scope behavior to the model just before moving up/down  I am getting an error if there is a record from other model that is "on it's way" up or down

Right now I'm trying to scope the tree using another behavior that extends the tree behavior but has
        $this->settings[$model->alias]['scope'] = array($model->alias . '.type' => $model->alias);
but saving record like this gives no lft,rght values bucause does not "see" the parent

Is there any way to fix this, to get it working or to look for other option?

Is there any option to use multiple trees inside one database. So the rght,lft values will be dublicated for every model but there will be no conflict because they will not "know" for each other.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: