$layout

From PHP on Trax

Jump to: navigation, search

It will first try to find a layout with the same name as the current controller if not then i will see if there is a default layout called application.phtml. in app/views/layouts if there is a file called application.phtml that will be used for all the pages. you can also in any of the controllers define a class variable $layout and that controller and any controller inheriting from that controller will use that layout.


<? public $layout "mylayout"# this will make it use app/views/layouts/mylayout.phtml ?>

You can also do the following: If you define the layout as above but the string is a function name in that controller or any controller it is inheriting from it will run that function and that function should return a string which is the layout name.


<?
public $layout "writers_and_readers";

function 
writers_and_readers() {
   return (
Session::get('logged_in') ? "writer_layout" "reader_layout");
}
?>

If say for just one action/controller function, you don't want to have a layout rendered you can define a class variable in the controller function $this->render_layout = false; and it won't have any layout or you. Or you can just set the $layout = "null";

Personal tools