Skip to content

Instantly share code, notes, and snippets.

@oddnoc
Created March 27, 2013 19:46
Show Gist options
  • Save oddnoc/5257417 to your computer and use it in GitHub Desktop.
Save oddnoc/5257417 to your computer and use it in GitHub Desktop.
A simple extension for SilverStripe 3.1 that restores the meta tag behavior of 3.0. Needs SiteTree::add_extension('MetadataExtension'); in your config.
class MetadataExtension extends DataExtension {
static $db = array(
'MetaTitle' => 'Varchar(255)',
'MetaKeywords' => 'Varchar(1024)',
);
function updateCMSFields(FieldList $fields) {
$metadata_field = $fields->fieldByName('Root.Main.Metadata');
$metatitle_field = new TextField('MetaTitle', $this->owner->fieldLabel('MetaTitle'));
$metakeywords_field = new TextareaField('MetaKeywords', $this->owner->fieldLabel('MetaKeywords'));
$metatitle_field
->setRightTitle(_t('SiteTree.METATITLEHELP',
'Replaces the page name in the HTML <title> element (requires template support).'))
->addExtraClass('help');
$metakeywords_field
->setRightTitle(_t('SiteTree.METAKEYWORDSHELP',
'A list of keywords (not used by search engines; does not appear in HTML without template support).'))
->addExtraClass('help');
$metadata_field->push($metakeywords_field);
$metadata_field->push($metatitle_field);
}
}
@blpraveen
Copy link

Hi Oddnoc,
Sapphire Framework 2.4 version includes MetaTile and Status
Similar way can we add Status Field to 3.1

@blpraveen
Copy link

Please let us know about this extension is fine https://gist.github.com/blpraveen/8c64f04f97cd43cbad3c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment