We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 04593d8 commit c31ff9dCopy full SHA for c31ff9d
src/components/PageMetaTagsFilter.php
@@ -0,0 +1,30 @@
1
+<?php
2
+/**
3
+ * @author Dmytro Karpovych
4
+ * @copyright 2016 NRE
5
+ */
6
+
7
+namespace nullref\cms\components;
8
9
10
+use nullref\cms\models\Page;
11
+use Yii;
12
+use yii\base\ActionFilter;
13
14
+class PageMetaTagsFilter extends ActionFilter
15
+{
16
+ public function beforeAction($action)
17
+ {
18
+ if (!Yii::$app->request->isAjax) {
19
+ $url = '/' . Yii::$app->request->pathInfo;
20
+ /** @var Page $page */
21
+ $page = Page::find()->byRoute($url)->one();
22
+ if ($page !== null) {
23
+ $view = $action->controller->view;
24
+ $page->registerMetaTags($view);
25
+ $view->params['cms.page'] = $page;
26
+ }
27
28
+ return parent::beforeAction($action);
29
30
+}
0 commit comments