Welcome Guest, Not a member yet? Register   Sign In
Which template method is better practice

I'm looking for a "good practique" for templating in codeigniter (actual version) (sorry for my bad english). All info I have founded is really old and has many options to do the same, but I can't understad which one of those methods are better of if there is a standar way for doing that. I'm gonna describe the best tree methods I have found in mi opinion and the idea is to know which one is a better choice (cleanest, simplest, and codeigniter patron oriented).

Method 1: extendidng controller class: I think that this method is easy to implement and very usefull, but it means to change all controllers logic

PHP Code:
class MY_Controller extends CI_Controller{

 public function 

 public function 
loadPage($contentView false$data = array()){
      if(!$contentView$contentView 'home';

and for the controllers do something like:

PHP Code:
class Pages extends MY_Controller {

Method 2: doing the same but with a loader (I'm not sure about how to do this)

Method 3: doing the same with a library (I'm not sure about how to do this)

Method 4: Doing a template view that loads the partials

Other methods that I don't know...

The idea is to have many templates, for example with top nav bar, another one with lef side menu and load the template in the contreoller passing expecifically the view who need to insert in the template (and it's data array).

Are one of these methods recommended? or any better way for doing this?

Messages In This Thread
Which template method is better practice - by carlosvo - 02-07-2020, 02:07 AM

Theme © iAndrew 2016 - Forum software by © MyBB