Skip to content

Commit

Permalink
PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Apr 8, 2024
1 parent d426370 commit 07f2821
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/Extension/Traits/FluentObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,25 @@ protected function updateFluentCMSFields(FieldList $fields)
$url = $owner->CMSEditLink();
$url = Director::makeRelative($url);

$summaryColumns['Title'] = [
'title' => 'Title',
'callback' => function (Locale $object) use ($url, $params): ?DBField {
if (!$object->RecordLocale()) {
return null;
if ($url) {
$summaryColumns['Title'] = [
'title' => 'Title',
'callback' => function (Locale $object) use ($url, $params): ?DBField {
if (!$object->RecordLocale()) {
return null;
}

$recordLocale = $object->RecordLocale();
$locale = $recordLocale->getLocale();
$params['l'] = $locale;
$localeLink = Controller::join_links($url, '?' . http_build_query($params));
$localeTitle = Convert::raw2xml($recordLocale->getTitle());
$render = sprintf('<a href="%s" target="_top">%s</a>', $localeLink, $localeTitle);

return DBField::create_field('HTMLVarchar', $render);
}

$recordLocale = $object->RecordLocale();
$locale = $recordLocale->getLocale();
$params['l'] = $locale;
$localeLink = Controller::join_links($url, '?' . http_build_query($params));
$localeTitle = Convert::raw2xml($recordLocale->getTitle());
$render = sprintf('<a href="%s" target="_top">%s</a>', $localeLink, $localeTitle);

return DBField::create_field('HTMLVarchar', $render);
}
];
];
}
}

// Let extensions override columns
Expand Down

0 comments on commit 07f2821

Please sign in to comment.