Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how fetch function works in cakephp layout view

Tags:

cakephp

I am new to CakePHP and would like to know as how these lines work in Cake

echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->fetch('script');

Where do the meta tag, css and javascript files that are being fetched come from?

like image 742
user1592129 Avatar asked Aug 11 '12 11:08

user1592129


1 Answers

$this->fetch('something');

According to the cakephp book , the fetch function is looking for blocks named something and echo them.

In your example, as far as I understand , it looks for something like that in your view:

$this->Html->script('carousel', array('inline' => false));
$this->Html->css('carousel', null, array('inline' => false));

and treat it as a block. so $this->fetch('script') will get all the html->script(....) and print them.

Read more : http://book.cakephp.org/2.0/en/views.html

like image 58
Ofir Baruch Avatar answered Oct 29 '22 12:10

Ofir Baruch