1 | <?php |
||
3 | class GalleryImage extends DataObject implements RenderableAsPortlet |
||
|
|||
4 | { |
||
5 | public static $db = array( |
||
6 | 'SortOrder' => 'Int', |
||
7 | 'Title' => 'Varchar', |
||
8 | 'Caption' => 'Text' |
||
9 | ); |
||
10 | |||
11 | // One-to-one relationship with gallery page |
||
12 | public static $has_one = array( |
||
13 | 'Image' => 'Image', |
||
14 | 'GalleryPage' => 'GalleryPage', |
||
15 | ); |
||
16 | |||
17 | // tidy up the CMS by not showing these fields |
||
18 | 1 | public function getCMSFields() |
|
28 | |||
29 | // Tell the datagrid what fields to show in the table |
||
30 | public static $summary_fields = array( |
||
31 | 'ID' => 'ID', |
||
32 | 'Title' => 'Title', |
||
33 | 'Thumbnail' => 'Thumbnail', |
||
34 | ); |
||
35 | |||
36 | // this function creates the thumnail for the summary fields to use |
||
37 | 1 | public function getThumbnail() |
|
41 | |||
42 | 1 | public function getPortletTitle() |
|
46 | |||
47 | /** |
||
48 | * An accessor method for an image for a portlet. |
||
49 | * |
||
50 | * @example |
||
51 | * <code> |
||
52 | * return $this->NewsItemImage; |
||
53 | * </code> |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 1 | public function getPortletImage() |
|
61 | |||
62 | /** |
||
63 | * An accessor for text associated with the portlet. |
||
64 | * |
||
65 | * @example |
||
66 | * <code> |
||
67 | * return $this->Summary |
||
68 | * </code> |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 1 | public function getPortletCaption() |
|
76 | } |
||
77 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.