@po47

Как подгрузить виды в переменную «content» yii?

Вопрос максимально простой, но никак не могу понять что делаю не так.
Создали новый шаблон в layout, добавили его в config/wep.php. Все ок.
<?php

use yii\helpers\Html;
use app\assets\AppAsset;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrapper">
        <div class="container">
                <?= Html::a('Ссылка 1', ['post/index.php']) ?>
                <?= Html::a('Ссылка 2', ['admin/index.php']) ?>
        </div>
                <?= $content ?>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>


Дальше создали новые контроллеры в папке Controllers
<?php

namespace app\controllers;

use yii\web\Controller;

class PostController extends Controller {
     
  public function actionPost()
    {
        return $this->render('index');
    }
}
?>


Добавили в папку view папки post и admin с файлами index.php
Через phptest/web/index.php?r=post ошибка:
"Not Found (#404)
Page not found.
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you."

Я так понимаю, он не находит папку с видом, но почему? Что не так?
  • Вопрос задан
  • 53 просмотра
Решения вопроса 1
myks92
@myks92 Куратор тега Yii
Нашёл решение — пометь вопрос ответом!
В вашем случае зарос будет такой:
http://phptest/web/index.php?r=post/post
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы