Answer the question
In order to leave comments, you need to log in
How to make breadcrumbs as links in Yii using NestedSet?
Good afternoon,
I made such a function in the model:
static function getBreadcrumbs($id){
$root = Product::model()->findByPk($id);
$ancestors = $root->ancestors()->findAll();
$arr = array();
$arr[] = "Главная";
foreach($ancestors as $one){
$item = CHtml::link($one->getName(), array('product/item/id/'.$id));
$arr[] = $item;
}
return $arr;
}
$breadcrumbs=$model->getBreadcrumbs((int)$_GET['id'])
$this->breadcrumbs = $breadcrumbs;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question