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 } } ?> 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"; 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! 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'; } } Link to comment https://forums.phpfreaks.com/topic/254228-layouts-in-cakephp/#findComment-1304454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.