I have implemented a view to show category structure using Yii2.
Users can navigate sub categories by clicking root category. Child categories are shown in the same page when page has been refreshed.
I need to show breadcrumbs according to category navigation. I set category titles according explanations. But it shows current category without showing the category hierarchy.
I have gone through few previously asked questions. But there were not a solution for my question.
How to create Yii2 Breadcrumbs
Yii2: How can I place something into a Breadcrumbs widget?
Is there anyone who has same kind of experience and found a solution?
Thanks.
=============================Edit==================================
$this->title = 'Curriculum Lists';
$request = Yii::$app->request;
//Get data
$get_data = $request->get();
//This is for page
if($get_data['cat'] === 'yes'){
$this->params['breadcrumbs'][] = $this->title;
}else{
$this->params['breadcrumbs'][] = ['label'=>$this->title, 'url'=>['category-list/categories', 'parentid' => "1", 'cat'=>'yes']];
}
//Get categories
$categories = (isset($dataProvider['categories'])) ? $dataProvider['categories'] : "";
//Get parent data
$parent = (isset($dataProvider['parent'])) ? $dataProvider['parent'] : "";
//Create breadcrumb for current category
if($get_data['cat'] === 'no'){
$this->params['breadcrumbs'][] = ['label' => $parent['category_list_value'], 'url' => ['category-list/categories', 'parentid'=>$parent['category_list_id'], 'cat'=>'no']];
}
//Show categories
if(!empty($categories)){
foreach ($categories as $cat) {
$pid = $cat['category_list_id'];
echo '<div>';
echo '<a href="index.php?r=category-list/categories&parentid='.$pid.'&cat=no">';
echo $cat['category_list_value']."- ".$pid;
echo '</a>';
echo '</div>';
}
}