Best way create layouts library vs extend CI_Controller |
Some time ago, one approach I used was to create a library "App\Libraries\Theme".
Then, use it as a service. Or, setting in a property of an abstract BaseController. It could be used like "$this->theme->render('view')", for example. To expedite, it has a "theme config". That could be set in the BaseController or other site area controllers that extends it. Then, many themes are possible. The "render" method automatically renders the view in the theme path, like "APPPATH . 'Views/theme-x/view-name.php'". The data of head, header, footer, etc, are passed with a setData() method. That allow pre-set array keys in the BaseController, like an User object created according the Session user_id. Hope it help. |
Messages In This Thread |
Best way create layouts library vs extend CI_Controller - by asalves - 01-06-2019, 03:43 AM
RE: Best way create layouts library vs extend CI_Controller - by natanfelles - 01-06-2019, 11:52 AM
RE: Best way create layouts library vs extend CI_Controller - by kilishan - 01-06-2019, 12:32 PM
|