This
clutters up the view template with code that is not relevant to the job in hand and as it happens all the time, is
ripe for automation. The easiest way to implement a better solution is to use what is known as the Two-Step
View design pattern. This is documented by Martin Fowler like this:
Two Step View deals with this problem by splitting the transformation into two stages. The first transforms
the model data into a logical presentation without any specific formatting; the second converts that logical
presentation with the actual formatting needed. This way you can make a global change by altering the
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
second stage, or you can support multiple output looks and feels with one second stage each. (From
http://www.martinfowler.com/eaaCatalog/twoStepView.html)
In terms of building a website with the Zend Framework, this means that the view script that is rendered
automatically by the ViewRenderer action helper should only contain the HTML related to that action. The rest
of the page is built up independently and the content of the controller action is placed into it. This is shown in
Figure 3.
Pages:
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98