I can't figure out at the moment why my view is not being displayed.
Controller: (/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)
<?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:
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');
in my default.ctp under /app/View/Layouts.
确保您的布局文件中有'echo $ this-> fetch('content')'。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.