我试图将视图发送到另一个视图然后渲染所有视图。但我不能
$app->get('/',function () use ($app) {
$data = array(
'content' => $app->view->fetch('home.php')
);
$app->render('layout.php', $data);
});
我怎么能用Slim Framework做到这一点?
答案 0 :(得分:0)
这样的东西应该在Slim框架的最新版本(2.4.0)中起作用:
$app->get('/',function () use ($app) {
$content = $app->view->fetch('home.php');
$app->render('layout.php', array('content' => $content));
});
在layout.php中
<html>
<?php echo $content; ?>
</html>
点击“查看模板数据”下的https://github.com/codeguy/Slim/releases