zelenin/yii2-tag-module Yii2 tag/category module

tagcategory

NOT MAINTAINED! DON'T USE!

Yii2 Tag/Category module

Yii2 tag/category module

Installation

Composer

The preferred way to install this extension is through Composer.

Either run

php composer.phar require zelenin/yii2-tag-module "dev-master"

or add

"zelenin/yii2-tag-module": "dev-master"

to the require section of your composer.json

Usage

Run:

php yii migrate --migrationPath=@Zelenin/yii/modules/Tag/migrations

Add behavior to model:

public function behaviors()
{
    return [
        'tag' => [
            'class' => 'Zelenin\yii\modules\Tag\behaviors\TagBehavior',
            'attributes' => [
                'tag' => [
                    'multiple' => true
                ],
                'category' => [
                    'multiple' => false
                ]
            ]
        ]
    ];
}

Create controllers for each attributes:

<?php

namespace backend\controllers;

use common\models\Post;
use Yii;
use Zelenin\yii\modules\Tag\controllers\DefaultController;

class PostTagController extends DefaultController
{
    public function init()
    {
        $this->modelClass = Post::className();
        $this->modelAttribute = 'tag';
        $this->entityName = 'Tags';
        parent::init();
    }
}

Now you can enter to tag/category CRUD - http://backend.yourdomain.com/post-tag/index.

Add widgets to view:

<div class="row">
    <?= $form->field($model, 'tag', ['options' => ['class' => 'form-group col-sm-6']])->widget(Tag::className(), []) ?>
    <?= $form->field($model, 'category', ['options' => ['class' => 'form-group col-sm-6']])->widget(Tag::className(), []) ?>
</div>

You can get tags via $model->tag.

Work in progress

Write your feature request to issues

Author

Aleksandr Zelenin, e-mail: aleksandr@zelenin.me

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



0.0.2 is the latest of one release



MIT license
Stats
11 github stars & 4 github forks
0 downloads in the last day
1 downloads in the last 30 days
266 total downloads