son.of.the.morning Posted January 2, 2012 Share Posted January 2, 2012 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 } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/254228-layouts-in-cakephp/ Share on other sites More sharing options...
jcombs_31 Posted January 2, 2012 Share Posted January 2, 2012 Change var $layout = "modal_box"; to $this->layout = "modal_box"; Quote Link to comment https://forums.phpfreaks.com/topic/254228-layouts-in-cakephp/#findComment-1303459 Share on other sites More sharing options...
son.of.the.morning Posted January 2, 2012 Author Share Posted January 2, 2012 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/254228-layouts-in-cakephp/#findComment-1303474 Share on other sites More sharing options...
rohitnanda Posted January 5, 2012 Share Posted January 5, 2012 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'; } } Quote Link to comment https://forums.phpfreaks.com/topic/254228-layouts-in-cakephp/#findComment-1304454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.