我是CakePHP 3中的新學員,請解決我的問題。 這是我控制文件:如何在cakephp 3.x中創建模板
DirectUseController.php
<?php
class DirectUseController extends AppController {
function index() {
$this->layout = 'directuse';
}
}
?>
這是我的佈局文件:
directuse.ctp
<!DOCTYPE html>
<html>
<head>
<title>
<?= $this->fetch('title') ?>
</title>
</head>
<body>
<a href="#"> Bootstrap </a> | <a href="#"> Foundation </a> | <a href="#"> Materilize </a>
<br><br>
Copyright
<br><br>
</body>
</html>
這是我的索引文件在直接使用的文件夾中 index.ctp
<section id="mainBody">
hello
</section>
和我的文件夾結構是:
我缺少什麼?
你正在使用哪個版本的蛋糕?因爲當你使用最新版本> 3.4'$ this-> layout ='directuse''時會產生錯誤。在這種情況下,你必須使用'$ this-> viewBuilder() - > setLayout('directuse');'。 – CodeWhisperer