Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added check to see if the DataObject actually has translation before …

…iterating over.
  • Loading branch information...
commit 8f922beff39da399ac243c1bd2704e29af39aec3 1 parent 242acac
Gus King authored simonwelsh committed
Showing with 15 additions and 13 deletions.
  1. +15 −13 code/model/Translatable.php
View
28 code/model/Translatable.php
@@ -1069,22 +1069,24 @@ function updateCMSFields(FieldList $fields) {
_t('Translatable.EXISTING', 'Existing translations'),
3
));
- if(!$tab->fieldByName('existingtrans')) {
+ if (!$tab->fieldByName('existingtrans')) {
$existingTransHTML = '<ul>';
- foreach($this->getTranslations() as $existingTranslation) {
- if($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
- $existingTransHTML .= sprintf(
- '<li><a href="%s">%s</a></li>',
- Controller::join_links(
- $existingTranslation->CMSEditLink(),
- '?locale='.$existingTranslation->Locale
- ),
- i18n::get_locale_name($existingTranslation->Locale)
- );
+ if ($existingTranslations = $this->getTranslations()) {
+ foreach ($existingTranslations as $existingTranslation) {
+ if ($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
+ $existingTransHTML .= sprintf(
+ '<li><a href="%s">%s</a></li>',
+ Controller::join_links(
+ $existingTranslation->CMSEditLink(),
+ '?locale=' . $existingTranslation->Locale
+ ),
+ i18n::get_locale_name($existingTranslation->Locale)
+ );
+ }
}
}
- $existingTransHTML .= '</ul>';
- $tab->push(new LiteralField('existingtrans',$existingTransHTML));
+ $existingTransHTML .= '</ul>';
+ $tab->push(new LiteralField('existingtrans', $existingTransHTML));
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.