Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class GalleryPage extends Page {
- public static $has_many = array(
- 'GalleryImages' => 'GalleryImage'
- );
- public static $defaults = array(
- 'ItemsperPage' => '10',
- 'ThumbnailImageWidth' => '100',
- 'ThumbnailImageHeight' => '100',
- 'FullImageWidth' => '800',
- 'FullImageHeight' => '600',
- );
- public function getCMSFields() {
- $fields = parent::getCMSFields();
- $gridFieldConfig = GridFieldConfig_RecordEditor::create();
- $gridFieldConfig->addComponent(new GridFieldBulkEditingTools());
- $gridFieldConfig->addComponent(new GridFieldBulkImageUpload());
- $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
- $gridfield = new GridField("GalleryImages", "Gallery Images", $this->GalleryImages()->sort("SortOrder"), $gridFieldConfig);
- $fields->addFieldToTab('Root.GalleryImages', $gridfield);
- return $fields;
- }
- }
- class GalleryPage_Controller extends Page_Controller {
- public static $allowed_actions = array (
- );
- public function Pagination() {
- // More info at http://doc.silverstripe.org/framework/en/howto/pagination
- $PaginatedList = new PaginatedList($this->data()->Images(), $this->request);
- $PaginatedList -> setPagelength(10);
- return $PaginatedList;
- }
- public function getGalleryImages() {
- return $this->GalleryImages()->sort("SortOrder");
- }
- public function init() {
- parent::init();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement