Codeigniter: Best way to structure partial views

后端 未结 7 1943
無奈伤痛
無奈伤痛 2020-11-29 19:39

How would you structure the below page in Codeigniter?

\"alt

I thought about creating seperate c

7条回答
  •  孤城傲影
    2020-11-29 19:54

    What I've done (in Kohana 2) is have the 1 template with all the sub sections (like left menu, top header), and a single controller that populates the variables that will be replaced in the template.

    Then, the variables for every sub-section can be generated by functions called in the controller itself. You can also have those functions be in a separate controller class's constructor, with every controller of yours extending that one so they're automatically ran and set as class variables for easy access.

    For slightly nicer templates you can have the subsections in separate files, and the big template include them:

    
    

提交回复
热议问题