我只是新的CakePhp,我想知道如何在另一个视图中调用视图。如何通过使用cakephp调用另一个视图中的视图
当我开始运行CakePhp时,默认布局位于view/layouts/default.ctp。
在default.thtml中我称为视图名称homeview(视图/家庭/ homeview.ctp)。
这里是我的代码:
<?php
echo $this->fetch('homeview'); // this statement here is work
?>
而在homeview.ctp我叫另一个名为displayphone视图(视图/家庭/ displayphone.ctp) homeview.ctp
<?php $this->start('homeview'); ?>
<h1> This is home view </h1>
<?php echo $this->fetch('displayphone'); // this statement does not work; ?>
<?php $this->end(); ?>
displayphone.ctp
<?php $this->start('displayphone');?>
<h1> This page display phone </h1>
<?php $this->end(); ?>
为什么我不能把在homeview displayphone块?
感谢现在运转。 – 2013-05-03 08:55:37
如何包含'ctp'? 'homeview'和'displayphone'都是同一个目录。我不需要做任何改变。我不想创建一个'元素' – Chinmay235 2014-09-10 04:40:33