Closed redd closed 9 years ago
I'm pretty sure your changes to _makeUnique()
is fetching all records, since $where
is never modified.
Yes that's right, this is because you can't simply put $model['slugfield'] => $translated_slug in conditions (and _makeUnique() recives translated slug as a param).
Shouldn't you be doing a wildcard search for the original slug, then looping through all the results that have that slug and do the comparison checks?
You are right, but any idea how to retrive original slug having translation?
I've never used the TranslateBehavior before, so what does it do to find() exactly?
It join's I18n table, but this is a bit complicated: http://api.cakephp.org/2.4/source-class-TranslateBehavior.html#96-188
Also after reciving original and translated content it replaces fields with translated ones: http://api.cakephp.org/2.4/source-class-TranslateBehavior.html#280-325
One more thing I've just remembered - you can't simply discover original slug (not translated) from model's table, because TranslateBehavior saves sometimes in model's table translated content (it depends on $model->locale while saving).
In model's table you can have content in many languages (while retriving it's overwritten by data from i18n table). So there is really no default/original value of data.
Hrmm, I'm going to have to setup a test locally to see how this works. Will get back to you on this.
Pull request for issue #27 with proper formatting.