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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -