Pulled out code necessary to create tag fields ba-sis style so that I could easily reuse it for personal FileTaxonomyExtension, Also added functionality that allows for easy-to-use and configure reverse tagging, ie. adding pages to the tag.
Example of File extension code used in current project:
class FileTaxonomyTermExtension extends DataExtension {
private static $belongs_many_many = array(
'Files' => 'File'
);
public function updateCMSFields(FieldList $fields) {
if ($this->owner->CanBeTagged)
{
$field = $this->owner->createReverseTagField('Files');
if ($field)
{
$fields->removeByName($field->getName());
$fields->addFieldToTab('Root.Main', $field);
}
}
}
}
<?php
class FileTaxonomyExtension extends DataExtension {
private static $many_many = array(
'Terms' => 'TaxonomyTerm',
);
public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.Main', TaxonomyTermExtension::create_field('Terms', 'Terms'));
}
}
Pulled out code necessary to create tag fields ba-sis style so that I could easily reuse it for personal FileTaxonomyExtension, Also added functionality that allows for easy-to-use and configure reverse tagging, ie. adding pages to the tag.
Example of File extension code used in current project: