【问题标题】:CakePHP, Can't seem to get a theme to applyCakePHP,似乎无法应用主题
【发布时间】:2010-09-19 22:57:48
【问题描述】:

我全新安装了 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>

\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>

我已经阅读了themes section of the 1.3 manual 和一些关于该主题的 other posts 但我还没有弄清楚。目前的输出是

输出

Controler = TestsController::index() Layout = No theme
test index, no theme, v2

我期待看到

Controler = TestsController::index() Layout = RGR
View=test index, RGR theme

我认为这是一个简单的错误,因为似乎没有其他人遇到同样的问题。我已经关闭了 core.php 中的捕获功能。

建议?

【问题讨论】:

    标签: cakephp themes


    【解决方案1】:

    您在控制器中错过了var $view = 'Theme'。这是必要的。

    【讨论】:

      猜你喜欢
      • 2015-10-15
      • 1970-01-01
      • 2011-01-08
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多