【发布时间】:2015-03-15 12:05:12
【问题描述】:
我正在经历 制作自定义应用程序 Web 应用程序开发的 Yii 2 章节 Mark Safronov 和 Jeffrey Winesett 使用 Yii 2 和 PHP。但是,我被困得很糟糕! 当我尝试(在 localhost wamp 服务器上运行高级模板)时,视图不会呈现... http://localhost/furni/frontend/web/index.php?r=customers 它触发的动作是..
class CustomersController extends Controller{
public function actionIndex() {
$records = $this->findRecordsByQuery();
$this->render('index', compact('records'));
return true;
}
.......
.......
}
请注意我的模型文件夹。它是客户,而视图/控制器文件夹/命名空间是客户s,带有 s。表是客户。
我的模型在 project-folder\frontend\models\customer
我在 project-folder\frontend\views\customers 中有 index.php 布局。
控制器位于 project-folder\frontend\controllers 中。我在视图文件中几乎什么都没有。..
<?php
$this->title = 'Index for customers';
?>
<div class="site-index">
Echo Out Loud
</div>
它在空白页中显示 1!
如果我把代码改成这个..
<?php
$this->title = 'Index for customers';
?>
<div class="site-index">
Echo Out Loud
</div>
<?php
die();
它呈现视图,但不包括页眉和页脚等的布局。没有头部标签,没有脚本,样式......什么都没有。
但是,站点控制器索引和其他预建视图可以正常渲染!没问题。拔头发时我错过了什么?
【问题讨论】: