Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Drawer extends Page {
- private static $db = array(
- 'SortOrder' => 'Int',
- );
- public static $has_many = array(
- 'DrawerLinks' => 'DrawerLink',
- );
- public function getCMSFields() {
- $fields = parent::getCMSFields();
- // don't show these in the CMS UI
- $fields->removeByName('BannerImage');
- $fields->removeByName('URLSegment');
- // "Navigation label"
- $fields->removeByName('MenuTitle');
- // "Page name"
- $fields->renameField('Title', 'Drawer Title');
- $fields->removeByName('H1');
- // Create a default configuration for the new GridField, allowing record editing
- $config = GridFieldConfig_RelationEditor::create();
- // Set the names and data for our gridfield columns
- $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
- // field from drawer class => label in UI
- 'Label' => 'Label',
- 'URL' => 'External URL',
- 'I_URL.Link' => 'Internal URL',
- 'Document.getURL' => 'Document',
- ));
- // Create a gridfield to hold the relationship
- $linksField = new GridField(
- 'DrawerLinks',
- 'DrawerLink',
- $this->DrawerLinks(),
- $config
- );
- $fields->addFieldToTab('Root.DrawerLinks', $linksField);
- return $fields;
- }
- }
- class Drawer_Controller extends Page_Controller {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement