Render view with alternate layout

Hi,

I have been looking at the documentation for the render() method in CController. It tells me it renders a view with a layout but I cannot find where it tells me to put the name of the layout I want it to render.

Any ideas?

read the

Guide and it will be understandable to you :)

Read it, and it has not told me what I am looking for. The only real thing I could find was this …

"Layout is implicitly applied when calling render(). By default, the view script protected/views/layouts/main.php is used as the layout. This can be customized by changing either CWebApplication::layout or CController::layout. To render a view without applying any layout, call renderPartial() instead."

Which seems to claim that I have to set it in some sort of config or as "global" setting which is not what I am looking for. I am looking for something more like this …

$this->render("Contacts"); // uses layout defined in config

$this->render("Contacts", "Box"); // uses the layout "box".

Any ideas? Is this possible?

You want to change it before you call the render, like so:




$this->layout = "Box";

$this->render("Contacts");



If that view is always to be viewed with the box layout, then add the $this->layout = "Box" line to the top of the view instead.

Brilliant, thanks this is what I was looking for.