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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.