diff --git a/common/messages/ru/app.php b/common/messages/ru/app.php
index 2cad3b4..eeb74a6 100755
--- a/common/messages/ru/app.php
+++ b/common/messages/ru/app.php
@@ -2,4 +2,5 @@
return [
'Contact' => "Контакты",
'About us' => 'О нас',
+ 'Home' => 'Главная',
];
\ No newline at end of file
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index 5cc245c..e23ab7c 100755
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -19,7 +19,7 @@
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\View;
- use yii\widgets\Breadcrumbs;
+ use frontend\widgets\SeoBreadcrumbs;
use \artbox\core\models\Language;
AppAsset::register($this);
@@ -426,15 +426,21 @@ _________________________________________________________ -->
= $seo->h1 ?>
- = Breadcrumbs::widget(
- [
- 'links' => isset($this->params[ 'breadcrumbs' ]) ? $this->params[ 'breadcrumbs' ] : [],
- 'homeLink' => [
- 'label' => \Yii::t('yii', 'Home'),
- 'url' => \Yii::$app->homeUrl.Language::$current->url,
- ]
- ]
- ) ?>
+ params['breadcrumbs']) && is_array($this->params['breadcrumbs']) ){
+ echo SeoBreadcrumbs::widget(
+ [
+ 'links' => $this->params[ 'breadcrumbs' ],
+ 'encodeLabels' => false,
+ 'homeLink' => [
+ 'label' => "". \Yii::t('app', "Home") ."",
+ 'url' => "/ru",
+ 'itemprop' => 'item',
+ ]
+ ]
+ );
+ }
+ ?>
diff --git a/frontend/widgets/SeoBreadcrumbs.php b/frontend/widgets/SeoBreadcrumbs.php
new file mode 100644
index 0000000..9b2e743
--- /dev/null
+++ b/frontend/widgets/SeoBreadcrumbs.php
@@ -0,0 +1,81 @@
+ '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]);
+ }
+ }
\ No newline at end of file
--
libgit2 0.21.4