'breadcrumb', 'itemscope' => true, 'itemtype' => " http://schema.org/BreadcrumbList" ]; public $encodeLabels = false; public $itemTemplate = "
  • {link}
  • \n"; public $homeLink = [ 'label' => 'Интернет-магазин светильников', 'url' => '/', 'itemprop' => 'item', ]; public $activeItemTemplate = '
  • {link}
  • '; 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,1); } elseif ($this->homeLink !== false) { $links[] = $this->renderItem_($this->homeLink, $this->itemTemplate, 1, true); } foreach ($this->links as $key => $link) { if (!is_array($link)) { $link = ['label' => $link]; } $links[] = $this->renderItem_($link, isset($link['url']) ? $this->itemTemplate : $this->activeItemTemplate, $key + 2); } echo Html::tag($this->tag, implode('', $links), $this->options); } protected function renderItem_($link, $template, $number, $home = false) { $encodeLabel = ArrayHelper::remove($link, 'encode', $this->encodeLabels); if (array_key_exists('label', $link)) { $label = $encodeLabel ? Html::encode($link['label']) : $link['label']; } else { throw new InvalidConfigException('The "label" element is required for each link.'); } if (isset($link['template'])) { $template = $link['template']; } if (isset($link['url'])) { $options = $link; unset($options['template'], $options['label'], $options['url']); if (!$home){ $label = "" . $label . ""; } $link = Html::a($label, $link['url'], $options); } else { $link = "$label"; } return strtr($template, ['{link}' => $link, '{number}' => $number]); } }