diff --git a/code/GridFieldExternalLink.php b/code/GridFieldExternalLink.php new file mode 100644 index 0000000..94c970b --- /dev/null +++ b/code/GridFieldExternalLink.php @@ -0,0 +1,67 @@ + 'col-buttons'); + } + + /** + * Add the title + * + * @param GridField $gridField + * @param string $columnName + * @return array + */ + public function getColumnMetadata($gridField, $columnName) { + if($columnName == 'Actions') { + return array('title' => ''); + } + return array(); + } + + /** + * Which columns are handled by this component + * + * @param type $gridField + * @return type + */ + public function getColumnsHandled($gridField) { + return array('Actions'); + } + + /** + * @param GridField $gridField + * @param DataObject $record + * @param string $columnName + * + * @return string - the HTML for the column + */ + public function getColumnContent($gridField, $record, $columnName) { + $data = new ArrayData(array( + 'Link' => method_exists($record, 'getExternalLink') ? $record->getExternalLink() : $record->ExternalLink + )); + + return $data->renderWith('GridFieldExternalLink'); + } +} diff --git a/templates/GridFieldExternalLink.ss b/templates/GridFieldExternalLink.ss new file mode 100644 index 0000000..52013e6 --- /dev/null +++ b/templates/GridFieldExternalLink.ss @@ -0,0 +1 @@ +<% _t('GridFieldExtensions.ExternalLink','External Link') %>