Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Page extends SiteTree {
- private static $db = array(
- 'showGallery' => 'Boolean',
- 'bgColor' => 'VarChar(7)'
- );
- private static $has_one = array(
- 'Background' => 'Image'
- );
- public static $has_many = array(
- 'GalleryImages' => 'GalleryImage'
- );
- // Create Grid Field
- public function getCMSFields() {
- $fields = parent::getCMSFields();
- $gridFieldConfig = GridFieldConfig::create()->addComponents(
- new GridFieldToolbarHeader(),
- new GridFieldAddNewButton('toolbar-header-right'),
- new GridFieldSortableHeader(),
- new GridFieldDataColumns(),
- new GridFieldPaginator(10),
- new GridFieldEditButton(),
- new GridFieldDeleteAction(),
- new GridFieldDetailForm()
- );
- $gridField = new GridField("GalleryImages", "Image Gallery", $this->GalleryImages(), $gridFieldConfig);
- $fields->addFieldToTab("Root.Gallery", $gridField);
- $fields->addFieldToTab("Root.Main", new UploadField('Background'));
- $fields->addFieldToTab('Root.Main', new TextField('bgColor', 'Background Color'));
- $fields->addFieldToTab('Root.Main', new CheckboxField('showGallery', 'Auto display gallery'));
- return $fields;
- }
- static $api_access = true;
- }
- class Page_Controller extends ContentController {
- /**
- * An array of actions that can be accessed via a request. Each array element should be an action name, and the
- * permissions or conditions required to allow the user to access it.
- *
- * <code>
- * array (
- * 'action', // anyone can access this action
- * 'action' => true, // same as above
- * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
- * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
- * );
- * </code>
- *
- * @var array
- */
- private static $allowed_actions = array ();
- public function init() {
- parent::init();
- // You can include any CSS or JS required by your project here.
- // See: http://doc.silverstripe.org/framework/en/reference/requirements
- // Ejemplo: Requirements::javascript("cms/javascript/LeftAndMain.js");
- // Ejemplo: Requirements::css("cms/css/TreeSelector.css");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement