CodeIgniter: Load controller within controller

后端 未结 10 1753
余生分开走
余生分开走 2020-11-28 07:43

I have a home controller with an index action that displays a set of featured products. However, the products are managed through a product

10条回答
  •  忘掉有多难
    2020-11-28 08:37

    There are plenty of good answers given here for loading controllers within controllers, but for me, this contradicts the mvc pattern.

    The sentence that worries me is;

    (filled with data processed by the product controller)

    The models are there for processing and returning data. If you put this logic into your product model then you can call it from any controller you like without having to try to pervert the framework.

    Once of the most helpful quotes I read was that the controller was like the 'traffic cop', there to route requests and responses between models and views.

提交回复
热议问题