Hi,

I'm also new cakephp, I'm even new to php, I've used the information
in this thread to come up with a (potential) solution for the
'multiple translations without creating a new record' problem. To do
this I've combined poLK's example code with yours.
A couple pointers;
In your update function you'll need to set the $this->data['{model}']
['id'] to the $id of the record where you want to add the translation.
Next, you need a new behaviour that extends TranslateBehaviour (see
TranslateItBeviour on how to do) , simply copy over the afterSave
function from the original translate behaviour (not from tranlateIt)
and replace if ($created)
with
                $localeExists = $this->_checkLocale($conditions);

                if ($created || (!$created && !$localeExists))

with _checkLocale;
        function _checkLocale($conditions){
                $this->_model->recursive = -1;
                return $translations = $this->_model->hasAny($conditions,
array('field'));
        }

So _checkLocale checks for the existance of a translation for the
record that you wish to translate. If a new record wasn't created and
there is no translation present, create the translation as you would
for a new record...

good luck!

As I said, I'm new, so I might have overlooked something important.

On 8 jun, 15:36, trickal <[EMAIL PROTECTED]> wrote:
> // update article record, this may mean that a new translation is
> added or an old one is updated
> function update($id = null) {
>         if (empty ($this->data)) {
>                 $this->Article->id = $id;
>                 $this->data = $this->Article->read();
>         } else {
>                 // set locale
>                 if (isset ($this->data['Article']['locale'])) {
>                         $this->Article->locale = 
> $this->data['Article']['locale'];
>                 }
>                 if ($this->Article->save($this->data['Article'])) {
>                         $this->flash('Article has been updated.', 
> '/articles');
>                 }
>         }
>
> }
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to