How much code should be in a CodeIgniter view?

后端 未结 7 1844
长发绾君心
长发绾君心 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:07

    When the templates need a lot of logic is could be useful to introduce the ViewModel pattern

    The logic that determines when a certain block is shown is placed in the view model.

    Example
    A template snippet:

    
        

    A view model snippet:

    $item['show_phone_number'] = $item["icq"] == '';
    

提交回复
热议问题