Здравствуйте! При открытии главной страницы вылетает данная ошибка:
Use of undefined constant canonical - assumed 'canonical'
1. in /var/www/u0432298/tests-sites.tk/views/site/index.php at line 13
45678910111213141516171819202122
4
5 use app\models\News;
6 use app\widgets\Alert;
7 use yii\helpers\Html;
8 use yii\bootstrap\Nav;
9 use yii\bootstrap\NavBar;
10 use yii\widgets\Breadcrumbs;
11
12 $this->title = 'STIGL';
13 $this->registerCssFile('http://'.$_SERVER['SERVER_NAME'], ['rel' => canonical])
14 ?>
15 <div class="main-video">
16 <video autoplay="" loop="" muted="">
17 <source src="/images/video/Stigl.mp4" type="video/mp4">
18 <source src="/images/video/Stigl.webm" type="video/webm">
19 <source src="/images/video/Stigl.ogv" type="video/ogg">
20 </video>
21 <a class="button_voice button_voice__mute mute"><span class="animMute"></span></a>
22 <div class="main-video-download">
Вот вьюха, где данная ошибка /views/site/index.php:
<?php
/* @var $this yii\web\View */
use app\models\News;
use app\widgets\Alert;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
$this->title = 'STIGL';
$this->registerCssFile('http://'.$_SERVER['SERVER_NAME'], ['rel' => canonical])
?>
SiteController.php
class SiteController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* {@inheritdoc}
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex()
{
//$this->layout = 'main';
//Прописываем шаблон для главной страницы
//Выводим из БД категории
// $news = News::find()->asArray();
// $count_news = count($news);
// $pages = new Pagination(['totalCount' => $count_news, 'pageSize' => 2, 'forcePageParam' => false, 'pageSizeParam' => false]);
// $news_array = $news->offset($pages->offset)->limit($pages->limit)->all();
// //debug($news_array);
//
// return $this->render('index', compact('count_news', 'news_array'));
$query = News::find()->asArray();
//Для постстраничной навигации
$count_news = count($query);
$pages = new Pagination(['totalCount' => $count_news, 'pageSize' => 2, 'forcePageParam' => false, 'pageSizeParam' => false]);
$news_array = $query->limit($pages->limit)->orderBy('data DESC')->all();
//Колличество товаров отображаемое на странице "В наличии: ...."
return $this->render('index', compact('news_array', 'count_news', 'pages'));
}
public function beforeAction($action)
{
$model = new Search();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$q = Html::encode($model->q);
return $this->redirect(Yii::$app->urlManager->createUrl(['page/search', 'q' => $q]));
}
return true;
}
}