Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TilePage extends Page {
- static $db = array(
- "LayoutType" => "Enum('2->1,1->2,3', '2->1')"
- );
- static $has_one = array(
- "BackgroundImage" => "Image"
- );
- static $has_many = array(
- "Tiles" => "Tile",
- "Tiles.ParentPage" => "Tile"
- );
- public function getCMSFields() {
- $fields = parent::getCMSFields();
- $fields->removeByName("Content");
- $fields->addFieldToTab("Root.Main", new UploadField("BackgroundImage", "Background Image"), "Metadata");
- $fields->addFieldToTab("Root.Tiles", new DropdownField("LayoutType", "Layout Type (LeftSize -> RightSize)", singleton("TilePage")->dbObject("LayoutType")->enumValues()));
- $fields->addFieldToTab("Root.Tiles", new GridField("Tiles", "Available Tiles", $this->Tiles(), GridFieldConfig_RecordEditor::create()));
- return $fields;
- }
- }
- class Tile extends DataObject {
- static $db = array(
- "Name" => "Varchar",
- "HorizontalSize" => "Int",
- "VerticalSize" => "Int",
- "Location" => "Enum('Left, Right', 'Left')",
- "Visible" => "Boolean",
- "Order" => "Int",
- "LinkToURL" => "Varchar(255)"
- );
- static $has_one = array(
- "BackgroundImage" => "Image",
- "ParentPage" => "Page",
- "LinkToPage" => "Page"
- );
- static $summary_fields = array(
- "Name", "Location", "Visible", "Order"
- );
- static $defaults = array(
- "Visible" => true
- );
- public function getCMSFields() {
- return new FieldList(
- new TextField("Name", "Name"),
- new DropdownField("ClassName", "Tile Type", array(
- "BasicTile" => "Basic Tile",
- "Tile" => "Image Only Tile",
- "ImageRotaterTile" => "Image Rotater Tile",
- "TextRotaterTile" => "Text Rotater Tile"
- )),
- new CheckboxField("Visible", "Visible"),
- new TextField("HorizontalSize", "Horizontal Tile Size (1, 2 or 3)", "", 1),
- new TextField("VerticalSize", "Vertical Tile Size (1, 2 or 3)", "", 1),
- new DropdownField("Location", "Location", singleton("Tile")->dbObject("Location")->enumValues()),
- new UploadField("BackgroundImage", "Background Image"),
- new TextField("Order", "Order (lower numbers will go first)"),
- new TreeDropdownField("LinkToPage", "Link to Page", "SiteTree"),
- new TextField("LinkToURL", "Link to URL (overrides Link to Page)")
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement