Commit 30258898481ebd007a12a307e412f71567221330
1 parent
2e6b55c4
настроить генерацию по шаблонам title и h1 для раздела отзывов
Showing
3 changed files
with
36 additions
and
7 deletions
Show diff stats
frontend/views/layouts/main.php
... | ... | @@ -136,6 +136,13 @@ $this->registerMetaTag( |
136 | 136 | ); |
137 | 137 | $module = \Yii::$app->getModule('feedback'); |
138 | 138 | $aliases = Alias::find()->where(['route' => '{"0":"site/questions"}'])->indexBy('route')->andWhere(['language_id' => Language::getCurrent()->id])->asArray()->all(); |
139 | +$commentUrl = Alias::find()->where(['route' => '{"0":"site/comments","service_id":0}'])->indexBy('route')->andWhere(['language_id' => Language::getCurrent()->id])->asArray()->all(); | |
140 | + | |
141 | + | |
142 | +# для автоматической генерации SEO параметров (title/description) в ситуациях, когда этих параметров нету | |
143 | +# мне нужно будет автоматически их подгенеривать, поэтому вместо $seo->title, которые является readOnly я использую эту переменную | |
144 | +$seoTitleName = $seo->title; | |
145 | + | |
139 | 146 | |
140 | 147 | ?> |
141 | 148 | |
... | ... | @@ -178,7 +185,22 @@ $this->registerMetaTag( |
178 | 185 | <meta name="viewport" content="width=device-width"> |
179 | 186 | <link type="image/x-icon" href="favicon.ico" rel="icon"> |
180 | 187 | <?= Html::csrfMetaTags() ?> |
181 | - <title><?=Html::encode($seo->title)?></title> | |
188 | + <?php | |
189 | + $serviceModel = new Service(['id' => $_GET['service_id']]); | |
190 | + $serviceName = $serviceModel->language->title; | |
191 | + if ($seo->title == '' | |
192 | + && \Yii::$app->controller->id == 'site' | |
193 | + && \Yii::$app->controller->action->id == 'comments' | |
194 | + ) { | |
195 | + | |
196 | + $seoTitleName = $this->params['breadcrumbs'][0] . ' - ' . $serviceName . ' - ' . \Yii::t('app', 'ABC short'); | |
197 | + | |
198 | + } | |
199 | + | |
200 | + | |
201 | + ?> | |
202 | + | |
203 | + <title><?= Html::encode($seoTitleName); ?></title> | |
182 | 204 | <?php $this->head() ?> |
183 | 205 | </head> |
184 | 206 | <body id="body"> |
... | ... | @@ -275,11 +297,15 @@ $this->registerMetaTag( |
275 | 297 | <div class="hidden-xs btn-header-wr"> |
276 | 298 | <span class="btn_ modal-link" data-form="write-to"><?=\Yii::t('app', 'Make an appointment') ?></span> |
277 | 299 | </div> |
278 | - | |
300 | + | |
279 | 301 | <ul class="hidden-xs hidden-sm"> |
280 | 302 | <li><a href="/vtoroe-mnenie" class="new"><span> <?=\Yii::t('app','Second thing')?> </span></a></li> |
281 | - <li><a href="<?=(isset($aliases['{"0":"site/questions"}'])) ? Url::to(['alias' => $aliases['{"0":"site/questions"}']]) : Url::to(['site/questions'])?>"><?=\Yii::t('app','Quest/Answer')?></a></li> | |
282 | - <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks')?></a></li> | |
303 | + <li> | |
304 | + <a href="<?= (isset($aliases['{"0":"site/questions"}'])) ? Url::to(['alias' => $aliases['{"0":"site/questions"}']]) : | |
305 | + Url::to(['site/questions']) ?>"><?= \Yii::t('app', 'Quest/Answer') ?></a></li> | |
306 | + <li> | |
307 | + <a href="<?= (isset($commentUrl)) ? Url::to(['/' . $commentUrl['{"0":"site/comments","service_id":0}']['value']]) : | |
308 | + Url::to(['site/comments']) ?>"><?= \Yii::t('app', 'Callbacks') ?></a></li> | |
283 | 309 | </ul> |
284 | 310 | <!-- --> |
285 | 311 | <!-- <div class="lang-sep-wr hidden-xs hidden-sm">--> | ... | ... |
frontend/views/service/view.php
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | use yii\web\View; |
16 | 16 | |
17 | 17 | $seo = \Yii::$app->get('seo'); |
18 | +# die(var_dump($seo)); | |
18 | 19 | $this->params['entity'] = Service::className(); |
19 | 20 | $this->params['entity_id'] = $model->id; |
20 | 21 | |
... | ... | @@ -142,10 +143,11 @@ JS; |
142 | 143 | <a class="packages-page-link" href="<?=Url::to(['alias' => $package->language->alias])?>"> |
143 | 144 | <div class="img-packages-page"> |
144 | 145 | <!--555x344--> |
145 | - <?=ImageHelper::set(($package->image) ? $package->image->getPath() : null) | |
146 | + <?= | |
147 | + ImageHelper::set(($package->image) ? $package->image->getPath() : null) | |
146 | 148 | ->cropResize(262, 185) |
147 | 149 | ->quality(84) |
148 | - ->renderImage()?> | |
150 | + ->renderImage(); ?> | |
149 | 151 | </div> |
150 | 152 | <div class="table-packages-wr"> |
151 | 153 | <table cellspacing="0" cellpadding="0" border="0"> | ... | ... |
frontend/views/site/comments.php
... | ... | @@ -26,7 +26,8 @@ |
26 | 26 | <div class="container"> |
27 | 27 | <div class="row"> |
28 | 28 | <div class="col-xs-12 col-sm-12"> |
29 | - <h1 class="title-pages"><?=\Yii::t('app','Callbacks')?></h1> | |
29 | + <h1 class="title-pages"> | |
30 | + <?= $data[$service_id] . ' - ' . \Yii::t('app', 'Callbacks') ?></h1> | |
30 | 31 | </div> |
31 | 32 | </div> |
32 | 33 | <div class="row"> | ... | ... |