2017 © Pedro Peláez
 

cakephp-plugin taxonomy

Simple Taxonomy plugin for CakePHP 3.x

image

bridn/taxonomy

Simple Taxonomy plugin for CakePHP 3.x

  • Sunday, September 28, 2014
  • by Bridn
  • Repository
  • 4 Watchers
  • 6 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

CakePHP 3.x Taxonomy Plugin

Simple Taxonomy Plugin, you will be able to add tags or categories etc. to your entity., (*1)

Requirements

  • CakePHP 3.x
  • CakePHP Migrations Plugin (Phinx >= v0.3.8)

1 - First, use Migrations plugin to create tables

cd to your app path
src/Console/cake migrations migrate -p Taxonomy

More information about Migrations at : http://github.com/cakephp/migrations, (*2)

2 - Load the Taxonomy plugin (app/config/bootstrap.php)

Plugin::load('Taxonomy', ['bootstrap' => false, 'routes' => true]);

3 - Add behaviors to your Table model :

public function initialize(array $config)
{
    $this->addBehavior('Taxonomy.TaxonomySync');
    $this->addBehavior('Taxonomy.TaxonomyFinder');
}
  • TaxonomySync Behavior create/update/clean your terms.
  • TaxonomyFinder Behavior manage all kind of queries. If you don't want to overload your queries, dettach it on the fly.

The Taxonomy plugin use polymorph associations, it is automatically associated to your model., (*3)

4 - Use the TaxonomyHelper to add tags to your content.

Add the helper to your content controller., (*4)

public $helpers = ['Taxonomy.Taxonomy'];

After each query on your content, the plugin will return an object and an array of terms attached to your content. The first parameter 'tag' will be used to group your terms in DB (don't translate this), the second must include your entity object, the third is an array of cakephp form params (label, row etc.) e.g. for a french form :, (*5)

<?= $this->Taxonomy->input('tag', $article, ['label' => __d('Taxonomy', 'Mots clés')]) ?>
<?= $this->Taxonomy->input('category', $article, ['label' => __d('Taxonomy', 'Categorie')]) ?>

5 - Queries in controller

To return all terms by table and type (articles controller) :, (*6)

$articles = $this->{$this->name}->find('all');
$categories = $this->{$this->name}->listAllTermsByType('category');
$this->set(compact('articles', 'categories'));

Or, (*7)

To return all relationships used by a table for a given term id (articles controller):, (*8)

$categories = $this->{$this->name}->listAllByTableAndByTerm($id);
$this->set(compact('categories'));

6 - Note

Separate your words with ";", (*9)

The Versions

28/09 2014

dev-dev

dev-dev https://github.com/Bridn/CakePHP-3.x-Taxonomy-Plugin

Simple Taxonomy plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp taxonomy

28/09 2014

dev-master

9999999-dev https://github.com/Bridn/CakePHP-3.x-Taxonomy-Plugin

Simple Taxonomy plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp taxonomy

28/09 2014

v0.3

0.3.0.0 https://github.com/Bridn/CakePHP-3.x-Taxonomy-Plugin

Simple Taxonomy plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp taxonomy

20/09 2014

v0.2

0.2.0.0 https://github.com/Bridn/CakePHP-3.x-Taxonomy-Plugin

Simple Taxonomy plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp taxonomy