php - How to call view in another view by using cakephp -
i new cakephp, wonder how call view in view.
when started run cakephp default layout located in view/layouts/default.ctp.
in default.ctp called view name homeview (view/homes/homeview.ctp).
here code:
<?php echo $this->fetch('homeview'); // statement here work ?>
and in homeview.ctp called view named displayphone (view/homes/displayphone.ctp) homeview.ctp
<?php $this->start('homeview'); ?> <h1> home view </h1> <?php echo $this->fetch('displayphone'); // statement not work; ?> <?php $this->end(); ?>
displayphone.ctp
<?php $this->start('displayphone');?> <h1> page display phone </h1> <?php $this->end(); ?>
why can not call displayphone block in homeview ?
as mentioned,
$this->fetch('homeview');
has created block name homeview, refer http://book.cakephp.org/2.0/en/views.html
as far calling view inside view not possible unless create element that. element common set of html can used in view file through out project. above purpose create element name "displayphone.ctp" in element folder inside view , call
$this->element('displayphone');
hope solve purpose.
Comments
Post a Comment