ArticleController.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
namespace frontend\modules\news\controllers;
use Yii;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
//
use frontend\modules\news\models\Article;
/**
* Class ArticleController
*
* @package frontend\modules\news\controllers
* @author FilamentV <vortex.filament@gmail.com>
* @copyright (c), Thread
*/
class ArticleController extends \frontend\components\BaseController
{
public $title = "Article";
public $defaultAction = 'index';
public $layout = "@app/layouts/base";
/**
*
*/
public function init()
{
parent::init();
$this->breadcrumbs = [
[
'label' => Yii::t('news', 'Blog'),
'url' => ['/news/list/index']
]
];
}
/**
* @return array
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'index' => ['get'],
],
],
];
}
/**
* @param $alias
* @return string
* @throws NotFoundHttpException
*/
public function actionIndex($alias)
{
$model = Article::getByAlias($alias);
if ($model == null) {
throw new NotFoundHttpException;
}
//group
// if ($model['group_id'] > 0) {
// $this->breadcrumbs[] = [
// 'label' => $model['group']['lang']['title'],
// 'url' => $model['group']->getUrl()
// ];
// }
//
$this->breadcrumbs[] = [
'label' => $model['lang']['title'],
];
//SEO
Yii::$app->metatag->registerModel($model);
//SEO
return $this->render('index', [
'model' => $model,
]);
}
}