mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 09:05:59 +00:00
Added check to see if the DataObject actually has translation before iterating over.
This commit is contained in:
parent
242acac7dd
commit
e5b95f9bb2
@ -1069,22 +1069,24 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
_t('Translatable.EXISTING', 'Existing translations'),
|
_t('Translatable.EXISTING', 'Existing translations'),
|
||||||
3
|
3
|
||||||
));
|
));
|
||||||
if(!$tab->fieldByName('existingtrans')) {
|
if (!$tab->fieldByName('existingtrans')) {
|
||||||
$existingTransHTML = '<ul>';
|
$existingTransHTML = '<ul>';
|
||||||
foreach($this->getTranslations() as $existingTranslation) {
|
if ($existingTranslations = $this->getTranslations()) {
|
||||||
if($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
|
foreach ($existingTranslations as $existingTranslation) {
|
||||||
$existingTransHTML .= sprintf(
|
if ($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
|
||||||
'<li><a href="%s">%s</a></li>',
|
$existingTransHTML .= sprintf(
|
||||||
Controller::join_links(
|
'<li><a href="%s">%s</a></li>',
|
||||||
$existingTranslation->CMSEditLink(),
|
Controller::join_links(
|
||||||
'?locale='.$existingTranslation->Locale
|
$existingTranslation->CMSEditLink(),
|
||||||
),
|
'?locale=' . $existingTranslation->Locale
|
||||||
i18n::get_locale_name($existingTranslation->Locale)
|
),
|
||||||
);
|
i18n::get_locale_name($existingTranslation->Locale)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$existingTransHTML .= '</ul>';
|
$existingTransHTML .= '</ul>';
|
||||||
$tab->push(new LiteralField('existingtrans',$existingTransHTML));
|
$tab->push(new LiteralField('existingtrans', $existingTransHTML));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user