在CakePHP 3.6布局中,我不会加载视图

时间:2018-06-26 11:33:11

标签: layout cakephp-3.0

<!DOCTYPE html>
<html lang="en">
<head>
<title><?= h($this->fetch('title')) ?></title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<!-- Include external files and scripts here (See HTML helper for more info.) -->


 <?php
    echo $this->fetch('meta');
    echo $this->fetch('css');
    echo $this->fetch('script');
    ?>
</head>
<body>

<!-- If you'd like some sort of menu to
show up on all of your views, include it here -->
<div id="header">
    <div id="menu">...</div>
</div>

<!-- Here's where I want my views to be displayed -->
<?= $this->fetch('content') ?>

<!-- Add a footer to each displayed page -->
<div id="footer">...</div>

</body>
</html>

嗨,

阅读CakePHP 3.6的文档可知,在Layout中,内容已加载到:<?= $this->fetch('content') ?>

在CakePHP 3.6中,视图保存在src / Template中

我的观点:src/Template/Casa/casa.ctp

这样,如果我创建一个名为casa.ctp的视图及其控制器CasaController.php,以便在布局中看到该视图,则应这样命名:<?= $this->fetch('casa') ?>

是这样吗?因为这就像我正在尝试,但对我不起作用,它不会加载任何内容,但也不会给我带来任何错误。

致谢

1 个答案:

答案 0 :(得分:0)

您需要在CasaController中执行Casa操作。

class CasaController extends AppController
{

    public function initialize()
    {
        parent::initialize();
    }

    public function casa()
    {

    }

}