简体   繁体   English

CakePHP 2.4忽略视图

[英]CakePHP 2.4 ignoring view

I can't figure out at the moment why my view is not being displayed. 目前,我不知道为什么未显示我的视图。

Controller: (/app/Controller/EventsController.php) 控制器:(/app/Controller/EventsController.php)

<?php

class EventsController extends AppController 
{
    public $helpers = array('Html', 'Form');

    function index() {
        $data = $this->Event->find('all');
        $this->set('data', $data);
    }

}

?>

View: (/app/View/Events/index.ctp) 查看:(/app/View/Events/index.ctp)

<?php

echo "<table border='1'>";

for($i=0; $i<count($data); $i++) 
{
    echo "<tr>";
        echo "<td>" . $data[$i]['Event']['Id'] . "</td>";
        echo "<td>" . $data[$i]['Event']['Start'] . "</td>";
    echo "<tr>";

}

echo "<table>";
//die;
?>

However, if I just uncomment die; 但是,如果我不加注释地死了; in my last line the content appears. 在我的最后一行中,内容出现了。 So it's not like it's being skipped, it's more like being ignored afterwards. 因此,这不像是被跳过,更像是事后被忽略。

Not sure if needed but my routes.php is pretty much standard: 不知道是否需要,但是我的routes.php非常标准:

Router::connect('/', array('controller' => 'events', 'action' => 'index', 'home'));

Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));

CakePlugin::routes();

require CAKE . 'Config' . DS . 'routes.php';

I accidentally removed my echo $this->fetch('content'); 我不小心删除了echo $this->fetch('content'); in my default.ctp under /app/View/Layouts. 在我的default.ctp / app / View / Layouts下。

确保您的布局文件中有'echo $ this-> fetch('content')'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM