i have implemented view show category structure using yii2.
users can navigate sub categories clicking root category. child categories shown in same page when page has been refreshed.
i need show breadcrumbs according category navigation. set category titles according explanations. shows current category without showing category hierarchy.
i have gone through few asked questions. there not solution question.
yii2: how can place breadcrumbs widget?
is there has same kind of experience , found solution?
thanks.
=============================edit==================================
$this->title = 'curriculum lists'; $request = yii::$app->request; //get data $get_data = $request->get(); //this 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 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 $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>'; } }
Comments
Post a Comment