diff --git a/code/GridFieldExternalLink.php b/code/GridFieldExternalLink.php new file mode 100644 index 0000000..cb54f2e --- /dev/null +++ b/code/GridFieldExternalLink.php @@ -0,0 +1,68 @@ + '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' => $record->hasMethod('getExternalLink') ? $record->getExternalLink() : $record->ExternalLink, + 'Text' => $record->hasMethod('getExternalLinkText') ? $record->getExternalLinkText() : 'External Link' + )); + + return $data->renderWith('GridFieldExternalLink'); + } +} diff --git a/templates/GridFieldExternalLink.ss b/templates/GridFieldExternalLink.ss new file mode 100644 index 0000000..cf82024 --- /dev/null +++ b/templates/GridFieldExternalLink.ss @@ -0,0 +1 @@ +$Text