user1364743
user1364743

Reputation: 5641

Call a .ctp file from a layout file with CakePHP

Is it possible to call a .ctp file from a layout which is also a .ctp file?

I have a default layout with the topbar, the footer and of course the variable $content_for_layout in the middle. I would like to dispatch the topbar and the footer into two others different .ctp files and I would like to call them from my layout.

Upvotes: 0

Views: 1697

Answers (2)

Doug Owings
Doug Owings

Reputation: 4448

You can use elements or, in CakePHP 2.1, you can check out blocks.

Upvotes: 2

Ross
Ross

Reputation: 17977

You can use elements.

<?php 
echo $this->element('topbar');
echo $content_for_layout;
echo $this->element('footer');
?>

Upvotes: 3

Related Questions