我只是新的CakePhp,我想知道如何在另一个视图中调用视图.
当我开始运行CakePhp时,默认布局位于view/layouts/default.ctp中.
在default.ctp中,我调用了一个视图名称homeview(view/homes/homeview.ctp).
这是我的代码:
<?php
echo $this->fetch('homeview'); // this statement here is work
?>
Run Code Online (Sandbox Code Playgroud)
在homeview.ctp中,我调用另一个名为displayphone的视图(view/homes/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(); ?>
Run Code Online (Sandbox Code Playgroud)
displayphone.ctp
<?php $this->start('displayphone');?>
<h1> This page display phone </h1>
<?php $this->end(); ?>
Run Code Online (Sandbox Code Playgroud)
为什么我不能在homeview中调用displayphone block?