Action View Helper in Zend - Work around?

后端 未结 4 2102
别跟我提以往
别跟我提以往 2020-12-16 18:49

I\'m working on building up an interface that I want to function as a \"tabbed browsing\" sort of function. Each of these tabs has already been written as an action and the

4条回答
  •  暖寄归人
    2020-12-16 19:07

    The Correct way to work around the action view helper, as I stated in the article you cited, is to create partials which access the model directly to fetch the data they need. This can be through a view helper (you make this yourself ;)) if this would involve a lot of logic in your view.

    The action view helper is plagued with more than just performance issues, but also creates horrendous debugging nightmares, and if you need it, then your application is probably not following MVC, and therefore, you are using the controller for reuse, instead of the model, which is the patterns intention.

    You can render partials from within your layout or current actions view with the render or partial methods of the view object.

    If you have multiple actions to deal with multiple possible posts from your tabs, then you should set all of these actions to render the same view script, which will then render all of the tabs with data direct from the model.

提交回复
热议问题