Compare View

switch
from
...
to
 
Commits (3)
backend/config/main.php
... ... @@ -2,6 +2,8 @@
2 2 use artbox\core\components\SeoUrlManager;
3 3 use artbox\core\models\Page;
4 4 use common\components\Sitemap;
  5 + use artbox\weblog\models\Article;
  6 + use common\models\Objectkb;
5 7  
6 8 $params = array_merge(
7 9 require( __DIR__ . '/../../common/config/params.php' ),
... ... @@ -94,15 +96,38 @@
94 96 ],
95 97 'urlManagerFrontend' => [
96 98 'class' => SeoUrlManager::className(),
97   - 'baseUrl' => '/',
98 99 'enablePrettyUrl' => true,
99 100 'showScriptName' => false,
100   - 'rules' => [],
  101 + // 'dontShowDefaulPrefix' => true,
  102 + 'rules' => [
  103 + '\/robots.txt' => 'site/robots',
  104 + ],
  105 + 'processRoutes' => [
  106 + 'object/view',
  107 + 'blog/article',
  108 + 'blog/tag',
  109 + 'blog/category',
  110 + 'page/view',
  111 + ],
101 112 ],
102 113 'sitemap' => [
103 114 'class' => Sitemap::className(),
104 115 'entities' => [
105 116 [
  117 + 'class' => Objectkb::className(),
  118 + 'conditions' => [
  119 + [ 'status' => 1 ],
  120 + ],
  121 + 'url' => 'object/view',
  122 + ],
  123 + [
  124 + 'class' => Article::className(),
  125 + 'conditions' => [
  126 + [ 'status' => 1 ],
  127 + ],
  128 + 'url' => 'blog/article',
  129 + ],
  130 + [
106 131 'class' => Page::className(),
107 132 'conditions' => [
108 133 [ 'in_menu' => 1 ],
... ...
backend/web/.gitignore
1 1 /index.php
2 2 /index-test.php
  3 +/sitemap.xml
... ...
common/components/Sitemap.php
... ... @@ -131,6 +131,7 @@
131 131 $urlManager->createAbsoluteUrl(
132 132 [
133 133 $entity[ 'url' ],
  134 + 'alias' => $record->lang->alias,
134 135 'id' => $record->getAttribute('id'),
135 136 ]
136 137 )
... ...
common/config/SitemapDynamic.php 100644 → 100755
1 1 <?php
2   -
3   - return [
4 2  
5   - ];
6 3 \ No newline at end of file
  4 +return [
  5 + 1 => [
  6 + 'entity' => 'common\\models\\Objectkb',
  7 + 'status' => '1',
  8 + 'frequency' => 'daily',
  9 + 'priority' => '0.9',
  10 + 'id' => 1,
  11 + ],
  12 + 2 => [
  13 + 'entity' => 'artbox\\weblog\\models\\Article',
  14 + 'status' => '1',
  15 + 'frequency' => 'weekly',
  16 + 'priority' => '0.8',
  17 + 'id' => 2,
  18 + ],
  19 + 3 => [
  20 + 'entity' => 'artbox\\core\\models\\Page',
  21 + 'status' => '1',
  22 + 'frequency' => 'weekly',
  23 + 'priority' => '0.6',
  24 + 'id' => 3,
  25 + ],
  26 +];
7 27 \ No newline at end of file
... ...
common/config/SitemapStatic.php 100644 → 100755
1 1 <?php
2   -
3   - return [
4 2  
5   - ];
6 3 \ No newline at end of file
  4 +return [
  5 + 1 => [
  6 + 'url' => 'http://www.new-kbenergy.test',
  7 + 'frequency' => 'always',
  8 + 'priority' => '1',
  9 + 'id' => 1,
  10 + ],
  11 + 2 => [
  12 + 'url' => 'http://www.new-kbenergy.test/ru/site/legal',
  13 + 'frequency' => 'daily',
  14 + 'priority' => '0.9',
  15 + 'id' => 2,
  16 + ],
  17 + 3 => [
  18 + 'url' => 'http://www.new-kbenergy.test/ru/site/individual',
  19 + 'frequency' => 'daily',
  20 + 'priority' => '0.9',
  21 + 'id' => 3,
  22 + ],
  23 +];
7 24 \ No newline at end of file
... ...
frontend/views/layouts/main.php
... ... @@ -23,6 +23,7 @@
23 23 use yii\web\View;
24 24 use yii\widgets\Breadcrumbs;
25 25 use common\models\Feedback;
  26 + use frontend\widgets\HreflangWidget;
26 27  
27 28 AppAsset::register($this);
28 29 $user = \Yii::$app->user->identity;
... ... @@ -71,6 +72,9 @@
71 72 <meta charset="<?= \Yii::$app->charset ?>">
72 73 <meta name="viewport" content="width=device-width, initial-scale=1">
73 74 <?= Html::csrfMetaTags() ?>
  75 +
  76 + <?= HreflangWidget::widget()?>
  77 +
74 78 <title><?= Html::encode($seo->title) ?></title>
75 79 <?php $this->head() ?>
76 80 </head>
... ...
frontend/views/site/index.php
... ... @@ -409,13 +409,21 @@ JS;
409 409 <iframe width="100%" height="100%" src="https://www.youtube.com/embed/NCNqrRzXpTw" frameborder="0" allowfullscreen=""></iframe>
410 410 </div>
411 411 <div class="post" style="background-image: url('/img/post_cover_2.jpg');">
412   - <a href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti" target="_blank">
  412 + <a
  413 + rel="nofollow"
  414 + href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti"
  415 + target="_blank"
  416 + >
413 417 <div class="title"><?=\Yii::t('app', 'index_medias3')?></div>
414 418 <div class="blue_arrow"></div>
415 419 </a>
416 420 </div>
417 421 <div class="post" style="background-image: url('/img/post_cover_3.jpg');">
418   - <a href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html" target="_blank">
  422 + <a
  423 + rel="nofollow"
  424 + href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html"
  425 + target="_blank"
  426 + >
419 427 <div class="title"><?=\Yii::t('app', 'index_medias4')?></div>
420 428 <div class="blue_arrow"></div>
421 429 </a>
... ...
frontend/views/site/media-about.php
... ... @@ -31,7 +31,11 @@ use yii\web\View;
31 31 <div class="col-sm-4">
32 32 <div class="box-image">
33 33 <div class="post" style="background-image: url('/img/post_cover_3.jpg');">
34   - <a href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html" target="_blank">
  34 + <a
  35 + rel="nofollow"
  36 + href="https://ecotechnica.com.ua/stati/2927-kakie-solnechnye-elektrostantsii-perspektivnee-kryshnye-ili-nazemnye.html"
  37 + target="_blank"
  38 + >
35 39 <div class="title"><?= \Yii::t('app', 'media_text2') ?></div>
36 40 </a>
37 41 </div>
... ... @@ -40,7 +44,11 @@ use yii\web\View;
40 44 <div class="col-sm-4">
41 45 <div class="box-image">
42 46 <div class="post" style="background-image: url('/img/post_cover_2.jpg');">
43   - <a href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti" target="_blank">
  47 + <a
  48 + rel="nofollow"
  49 + href="http://censor.net.ua/resonance/322240/kak_ya_stal_nezavisimym_ot_veernyh_otklyucheniyi_pervaya_domashnyaya_elektrostantsiya_v_kievskoyi_oblasti"
  50 + target="_blank"
  51 + >
44 52 <div class="title"><?= \Yii::t('app', 'media_text3') ?></div>
45 53 </a>
46 54 </div>
... ...
frontend/widgets/HreflangWidget.php 0 → 100644
  1 +<?php
  2 + namespace frontend\widgets;
  3 +
  4 + /**
  5 + * User: timur
  6 + * Date: 17.02.18
  7 + * Time: 8:29
  8 + */
  9 +
  10 + use yii\base\Widget;
  11 + use artbox\core\models\Language;
  12 + use yii\helpers\Url;
  13 +
  14 + /**
  15 + * Class HreflangWidget
  16 + *
  17 + * @property Language[] $languages
  18 + *
  19 + * @package frontend\widgets
  20 + */
  21 + class HreflangWidget extends Widget
  22 + {
  23 +
  24 + public $languages;
  25 +
  26 + public function init()
  27 + {
  28 + parent::init();
  29 +
  30 + if(!isset($this->languages)){
  31 + $this->languages = Language::getActive();
  32 + }
  33 +
  34 + }
  35 +
  36 + public function run()
  37 + {
  38 +
  39 + foreach ($this->languages as $language){
  40 +
  41 + ?>
  42 +
  43 + <link
  44 + rel="alternate"
  45 + hreflang="<?=$language->url?>"
  46 + href="<?=Url::to(
  47 + [ \Yii::$app->requestedRoute ] +
  48 + \Yii::$app->request->get() +
  49 + [ 'language_id' => $language->id ],
  50 +
  51 + true
  52 + )?>"
  53 + >
  54 +
  55 + <?php
  56 +
  57 + }
  58 +
  59 +
  60 + parent::run();
  61 + }
  62 + }
0 63 \ No newline at end of file
... ...