dnadesign/silverstripe-tagurit

An alternative taxonomy module, providing protected types, and inverting the Tag/Type relationship to Type/Tag

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 8

Forks: 2

Open Issues: 2

Type:silverstripe-vendormodule

dev-master 2023-11-21 03:11 UTC

This package is auto-updated.

Last update: 2024-10-21 05:02:33 UTC


README

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