yii2yii2-basic-appgii

Yii2 Two different way for breadcrumbs


I have a gii generated view.php page, which can be reached from two different paths, but the breadcrumbs is the same. Anyone know how to fix?

Let me explain: I have the view.php view which shows the summary of the report made and can be reached from two paths:


Solution

    1. You have 2 options to know where it came from:
    1. Then do a switch to build the link:

      switch(value) {
        case 'creation':
         $label = 'CREATION';
         $url = 'url_of_creation';
         break;
        case 'summary':
         $label = 'SUMMARY';
         $url = 'url_of_summary'; 
         break;
      }
      
    2. Then just do something like this:

    $this->params['breadcrumbs'][] = ['label' => $label, 'url' => $url];