How much code should be in a CodeIgniter view?

后端 未结 7 1846
长发绾君心
长发绾君心 2020-12-29 13:44

First steps are done, some pages are coded. And after looking to the result I\'ve got the question... how much code is there should be in templates (View)?

For examp

7条回答
  •  死守一世寂寞
    2020-12-29 14:26

    View is no a template.

    Or at least - it should not be a template. Views are generally instance of classes, which are responsible for dealing with presentational logic. They juggle multiple templates and decide which one to use and what data pass into them.

    But CI has none of this. You are basically stuck with a template, which pretends to be "View" , and and instances of ActiveRecord, which they tell you are "Models". Hell .. in proper MVC the Model isn't even a specific class but an application layer.

    In long term, this situation will force both presentation logic and business logic into the controller, while at the same time, producing hard-to-maintain templates and activerecord classes.

提交回复
热议问题