Skip to content

Commit

Permalink
Only suffix unique URLSegment if enforce_global_unique_urls=true (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Sep 5, 2013
1 parent 69adec9 commit 15e9037
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion code/model/Translatable.php
Expand Up @@ -1439,7 +1439,12 @@ function createTranslation($locale, $saveTranslation = true) {
} else { } else {
$urlSegment = $newTranslation->URLSegment; $urlSegment = $newTranslation->URLSegment;
} }
$newTranslation->URLSegment = $urlSegment . '-' . i18n::convert_rfc1766($locale);
// Only make segment unique if it should be enforced
if(Config::inst()->get('Translatable', 'enforce_global_unique_urls')) {
$newTranslation->URLSegment = $urlSegment . '-' . i18n::convert_rfc1766($locale);
}

// hacky way to set an existing translation group in onAfterWrite() // hacky way to set an existing translation group in onAfterWrite()
$translationGroupID = $this->getTranslationGroup(); $translationGroupID = $this->getTranslationGroup();
$newTranslation->_TranslationGroupID = $translationGroupID ? $translationGroupID : $this->owner->ID; $newTranslation->_TranslationGroupID = $translationGroupID ? $translationGroupID : $this->owner->ID;
Expand Down

0 comments on commit 15e9037

Please sign in to comment.