Jump to content

Layouts in cakephp


son.of.the.morning

Recommended Posts

I am having trouble having different layout for different actions from my controller

 

<?php
class ContactsController extends AppController {
	var $name = "Contacts";
	var $layout = "default";

	function index() {
	}

	function edit_contacts(){
		$this->set('contacts', $this->Contact->find('all'));
                        var $layout = "modal_box"; // i want this layout to have this action

	}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/254228-layouts-in-cakephp/
Share on other sites

think it should be pretty simple. In your app_controller, you could

probably just add this, likely in the afterFilter() method, so that

you can process any login info first:

 

function afterFilter () {

 

    if ( $isUserLoggedIn ) {

        $this->layout = 'logged_in_layout';

    } else {

        $this->layout = 'some_other_layout';

    }

}

Link to comment
https://forums.phpfreaks.com/topic/254228-layouts-in-cakephp/#findComment-1304454
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.