yii\widgets\Breadcrumbs::run PHP Method

run() public method

Renders the widget.
public run ( )
    public function run()
    {
        if (empty($this->links)) {
            return;
        }
        $links = [];
        if ($this->homeLink === null) {
            $links[] = $this->renderItem(['label' => Yii::t('yii', 'Home'), 'url' => Yii::$app->homeUrl], $this->itemTemplate);
        } elseif ($this->homeLink !== false) {
            $links[] = $this->renderItem($this->homeLink, $this->itemTemplate);
        }
        foreach ($this->links as $link) {
            if (!is_array($link)) {
                $link = ['label' => $link];
            }
            $links[] = $this->renderItem($link, isset($link['url']) ? $this->itemTemplate : $this->activeItemTemplate);
        }
        echo Html::tag($this->tag, implode('', $links), $this->options);
    }

Usage Example

Exemplo n.º 1
0
 public function run()
 {
     $default = Lang::getLang()->code;
     $currentCode = \Yii::$app->language;
     foreach ($this->links as &$link) {
         if (is_array($link) && $default != $currentCode) {
             $link['url']['lang'] = $currentCode;
         }
     }
     return parent::run();
 }
All Usage Examples Of yii\widgets\Breadcrumbs::run