Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ToggleCompositeField question (Metadata etc) - 3.01


Go to End


3 Posts   2879 Views

Avatar
yurigoul

Community Member, 203 Posts

18 September 2012 at 6:28pm

In sitetree.php I found how the metadata-thingy that is there is created. I suspect one can use it to create ones own. The next question is: How can one remove it? Anybody?

Thnx!

ToggleCompositeField::create('Metadata', _t('SiteTree.MetadataToggle', 'Metadata'),
						array(
							new TextField("MetaTitle", $this->fieldLabel('MetaTitle')),
							new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1),
							new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')),
							new TextareaField("ExtraMeta",$this->fieldLabel('ExtraMeta'))
						)
					)->setHeadingLevel(4)

Avatar
Willr

Forum Moderator, 5523 Posts

22 September 2012 at 5:18pm

Well provided it plays nicely with the form API then you can just remove it like you do any other form fields on your page

class Page extends SiteTree {
..

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName('Metadata');
}
}

Avatar
yurigoul

Community Member, 203 Posts

22 September 2012 at 8:03pm

Thanks!