Hello,

I got it at last.
Obviously The book and several other tutorials are not that updated. I
got the answer scanning the Jobeet tutorial.
In order to have no errors while updating i18n sluggable items you
have to define in your data model what will the slug will be unique
by.
An example would be:
  actAs:
    I18n:
      fields: [title, description, excerpt]
      actAs:
        Sluggable: { fields: [title], uniqueBy: [lang, title] }

Dont really know the internal mechanism because previously I did have
unique slug for every language but this way it works.

Merry coding,
Anton
On Mar 4, 5:55 pm, "Olivier." <fac...@gmail.com> wrote:
> Hi,
>
> I don't understand the way the Sluggable Behavior act on an update.
>
> For me, if the canUpdate option is set to true and you get a change on
> one of the field "parent" of the slug, then he must update himself.
>
> It's why i made a change on the preUpdate method of the listener :
>
> File : /sfProject/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/
> vendor/doctrine/Doctrine/Template/Listener/Sluggable.php
> Line : 76
>
>     public function preUpdate(Doctrine_Event $event)
>     {
>         if (false !== $this->_options['unique']) {
>             $record = $event->getInvoker();
>             $name = $record->getTable()->getFieldName($this->_options
> ['name']);
>
>             $test = array_intersect($this->_options['fields'],
> array_keys($record->getModified()));
>
>             if ( ! $record->$name ||
>             (false !== $this->_options['canUpdate'] &&
>             !empty($test))) {
>                 $record->$name = null;
>                 $record->$name = $this->buildSlug($record);
>             }
>         }
>     }
>
> (I add  $record->$name = null; because if it's not null the value is
> not re-generated because of $proposal = $record->$name ? $record->
> $name : $slugFromFields; in getUniqueSlug() line 135.)
>
> I'm not sure it's the best way to handle this, but it works.
>
> What you thing of this modification ?
>
> Regards,
> Olivier.
>
> PS : I hope i make me clear, cause my english is a bit rusty ^^

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to