public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab("Root.Main", new UploadField('Image', 'Main Image'), 'Content');
     $fields->removeByName("Author");
     if ($this->owner->ClassName == "BlogEntry") {
         $fields->removeByName("Date");
     } else {
         $fields->renameField("Date", "Published Date");
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     //change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
     /** @var TextField $titleField */
     $titleField = $fields->dataFieldByName('Title');
     if ($titleField->Title() == 'Page name') {
         $fields->renameField('Title', 'Primary Heading');
     }
     //Add secondary heading - H2
     $fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
     $traits = $this->traitsUsedRecursive($this->owner->ClassName);
     if ($this->owner->config()->get('has_on_after_update_cms_fields')) {
         $traits[] = 'HasOnAfterUpdateCMSFieldsExtensionPoint';
     }
     if (!in_array('HasOnAfterUpdateCMSFieldsExtensionPoint', $traits)) {
         $this->afterUpdateCMSFields($fields);
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $gridFieldConfig = GridFieldConfig_RecordEditor::create();
     $gridFieldConfig->addComponent(new GridFieldBulkUpload());
     $gridFieldConfig->addComponent(new GridFieldGalleryTheme('Image'));
     $bulkUpload = $gridFieldConfig->getComponentByType('GridFieldBulkUpload');
     $bulkUpload->setUfSetup('setFolderName', "Managed/PhotoGalleries/" . $this->owner->ID . "-" . $this->owner->URLSegment);
     $bulkUpload->setUfConfig('canAttachExisting', false);
     $bulkUpload->setUfConfig('canPreviewFolder', false);
     $gridFieldConfig->removeComponentsByType('GridFieldPaginator');
     $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
     $gridFieldConfig->addComponent(new GridFieldPaginator(100));
     $gridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
     $gridfield = new GridField("PhotoGalleryImages", "Image Gallery", $this->owner->PhotoGalleryImages()->sort("SortOrder"), $gridFieldConfig);
     $fields->addFieldToTab('Root.ImageGallery', $gridfield);
     $fields->addFieldToTab('Root.ImageGallery', new LiteralField('help', "\n\t\t\t<h2>To upload new images:</h2>\n\t\t\t<ol>\n\t\t\t<li>1. Click the <strong>From your computer</strong> button above.</li>\n\t\t\t<li>2. <strong>Locate and select</strong> the image(s) you wish to upload.</li>\n\t\t\t<li>3. Click on <strong>Open/Choose</strong> and the image(s) will begin to upload.</li>\n\t\t\t<li>4. Click <strong>Finish</strong>.</li> \n\t\t\t</ol>"));
     $fields->renameField("Content", "Top Content");
     return $fields;
 }
    public function updateCMSFields(FieldList $fields)
    {
        //change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
        /** @var TextField $titleField */
        $titleField = $fields->dataFieldByName('Title');
        if ($titleField->Title() == 'Page Name') {
            $fields->renameField('Title', 'Primary Heading');
        }
        //Add secondary heading - H2
        $fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
        //Move meta fields to their own tab
        /** @var ToggleCompositeField $metaDataChildren */
        $metaDataChildren = $fields->fieldByName('Root.Main.Metadata');
        $children = array_merge([$metaTitle = TextField::create('MetaTitle')], $metaDataChildren->getChildren()->toArray());
        $fields->removeFieldFromTab('Root.Main', 'Metadata');
        $fields->addFieldToTab('Root', Tab::create('Metadata'), 'Content');
        //Add META Title tag to METADATA
        $fields->addFieldsToTab('Root.Metadata', $children);
        $metaTitle->setDescription('Displayed as the tab/window name; Also displayed in search engine result listings as the page title.<br />
									Falls back to the Primary Heading field if not provided.');
    }
Example #5
0
 public function testRenameField()
 {
     $fields = new FieldList();
     $nameField = new TextField('Name', 'Before title');
     $fields->push($nameField);
     /* The title of the field object is the same as what we put in */
     $this->assertSame('Before title', $nameField->Title());
     /* The field gets renamed to a different title */
     $fields->renameField('Name', 'After title');
     /* The title of the field object is the title we renamed to, this
     			includes the original object we created ($nameField), and getting
     			the field back out of the set */
     $this->assertSame('After title', $nameField->Title());
     $this->assertSame('After title', $fields->dataFieldByName('Name')->Title());
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->renameField('SkipToMainContentAccessKey', _t('AccessKey.SKIP_TO_MAIN_CONTENT_ACCESS_KEY'));
     $fields->addFieldToTab('Root.FacebookMetadata', new UploadField('FacebookLogo', _t('Facebook.METADATA_LOGO', 'Image that will show in facebook when linking to this site. The image should be a square of minimum size 200px')));
 }