CakePHP,似乎无法应用主题
我全新安装了 CakePHP 1.3.4 Stable。我创建了一个非常简单的应用程序,我试图让它使用主题目录视图和布局而不是默认的。
\app\controllers\tests_controller.php
<?php
class TestsController extends AppController {
var $name = 'Tests';
var $uses = array();
var $theme = 'rgr';
function index() {
$this->theme = 'rgr';
$this->layout = 'default';
echo "Controler = TestsController::index() ";
}
}
\app\views\layouts\default.ctp
<?php echo $html->docType(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
Layout = No theme
<?php echo $content_for_layout; ?>
</body>
</html>
\app\views\tests\index.ctp
<div class="test index">
test index, no theme
</div>
< strong>\app\views\themed\rgr\layouts\default.ctp
<?php echo $html->docType(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
Layout = RGR
<?php echo $content_for_layout; ?>
</body>
</html>
\app\views\themed\rgr\tests\index.ctp
<div class="test index">
View=test index, RGR theme
</div>
我已阅读 1.3 手册的主题部分,以及一些有关该主题的其他帖子 但我还没有弄清楚。目前输出是
输出,
Controler = TestsController::index() Layout = No theme
test index, no theme, v2
我希望看到
Controler = TestsController::index() Layout = RGR
View=test index, RGR theme
我认为这是一个简单的错误,因为似乎没有其他人遇到同样的问题。我已经关闭了 core.php 中的捕获。
建议?
I have a fresh install of CakePHP 1.3.4 Stable. I created a very simple application and i am trying to get it to use the theme directory view and layout instead of the default.
\app\controllers\tests_controller.php
<?php
class TestsController extends AppController {
var $name = 'Tests';
var $uses = array();
var $theme = 'rgr';
function index() {
$this->theme = 'rgr';
$this->layout = 'default';
echo "Controler = TestsController::index() ";
}
}
\app\views\layouts\default.ctp
<?php echo $html->docType(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
Layout = No theme
<?php echo $content_for_layout; ?>
</body>
</html>
\app\views\tests\index.ctp
<div class="test index">
test index, no theme
</div>
\app\views\themed\rgr\layouts\default.ctp
<?php echo $html->docType(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
Layout = RGR
<?php echo $content_for_layout; ?>
</body>
</html>
\app\views\themed\rgr\tests\index.ctp
<div class="test index">
View=test index, RGR theme
</div>
I have read the themes section of the 1.3 manual, and a few other posts on the subject But I have yet to figure it out. Currently the out put is
Output
Controler = TestsController::index() Layout = No theme
test index, no theme, v2
I expected to see
Controler = TestsController::index() Layout = RGR
View=test index, RGR theme
I'm thinking its a simple mistake as there does not seem to be anyone else with the same problem. I have turned off catching in the core.php.
Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在控制器中错过了
var $view = 'Theme'
。这是必要的。You missed
var $view = 'Theme'
in the controller.That's necessary.