Welcome Guest, Not a member yet? Register   Sign In
Best way create layouts library vs extend CI_Controller
#2

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.
Reply


Messages In This Thread
RE: Best way create layouts library vs extend CI_Controller - by natanfelles - 01-06-2019, 11:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB