B
B
balex7772019-11-06 10:24:22
Yii
balex777, 2019-11-06 10:24:22

How to display category tree in Grid View in yii2 like in WordPress?

How to display category tree in Grid View in yii2 like in WordPress?
like this 5dc2751c0a4ee495540138.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-11-06
@balex777

Like this if you work with NestedSets

/**
 * @property integer $id
 * @property string $name
 * @property string $slug
 * @property string $title
 * @property string $description
 * @property integer $lft
 * @property integer $rgt
 * @property integer $depth
 * @property Meta $meta
 *

[
                        'attribute' => 'name',
                        'value' => function (Category $model) {
                            $indent = ($model->depth > 1 ? str_repeat('  ', $model->depth - 1) . ' ' : '');
                            return $indent . Html::a(Html::encode($model->name), ['view', 'id' => $model->id]);
                        },
                        'format' => 'raw',
                    ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question