creocoder / yii2-nested-sets

The nested sets behavior for the Yii framework.
Other
446 stars 129 forks source link

Breadcrumbs? #103

Closed kwazaro closed 8 years ago

kwazaro commented 8 years ago

How to get data in format for yii\widgets\Breadcrumbs for node?

kapets commented 8 years ago
$categories = Categories::findOne(['id' => $model->id]);
$parents = $categories->parents()->all();
$this->title = $model->title;

if($parents){
    foreach ($parents as $item) {
        $this->params['breadcrumbs'][] = ['label' => $item->title, 'url' => ['**/catalog/categories/view**', 'id' => $item->id]];
    }
}
$this->params['breadcrumbs'][] = $this->title;

P.S. change url (/catalog/categories/view)

kwazaro commented 8 years ago

Thanks!