Skip to content

Latest commit

 

History

History
75 lines (57 loc) · 1.31 KB

File metadata and controls

75 lines (57 loc) · 1.31 KB

Tag ur it!

An alternative taxonomy module for SilverStripe

Introduction

This module inverts the term/type relationship to type/term and allows setting default/protected types/terms

Requirements

  • SilverStripe 4.4
  • GridFieldExtensions 3.2

Installation

Include the following in your composer.json and run composer update:

"require": {
    dnadesign/silverstripe-tagurit
}
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/dnadesign/silverstripe-tagurit.git"
        }
    ],

Configure the yml:

tagurit_protected_taxonomy:
  Type one:
    - Term
    - Second Term
  Second type:
    - Another Term

On your page, use the trait

    use TaxonomyTrait;

     private static $many_many = [
        'CustomTerms' => TaxonomyTerm::class
    ];
    
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $fields->addFieldsToTab(
            'Root.Terms',
            [
                ListboxField::create(
                    'CustomTerms',
                    'Custom Terms',
                    $this->getTermsForType('Second type')
                ),
            ]
        );

        return $fields;
    }

Run the build task:

vendor/silverstripe/framework/sake dev/build flush=1