Defining the Views Next we'll create the views that correspond to these three actions: one for the home page, one for the /about/ page, and one for the /about/you/ page. The home page view should be placed in the directory /application/modules/default/views/ scripts/index/, and the other two in /application/modules/default/views/ scripts/about/. These views are presented in Listings 25-4, 25-5, and 25-6, respectively. Each of these views is intended to demonstrate different facets of the behavior of views. Listing 25-4. The index.phtml View <?php <div id="header">Next Chess Club Meeting: April 12</div> <p> Welcome to our Chess Club's Web site! We're a bunch of chess enthusiasts <?php Listing 25-5. The index.phtml View <?php <div id="header">About Our Chess Club</div> <p> <?php Listing 25-6. The you.phtml View <?php <div id="header">About You!</div> <p> <?php As demonstrated in these views, you should pass all data originating in the controller through the escape() method, as it will properly filter data through PHP's htmlspecialchars() function. You'll see each of these views refer to header.phtml and footer.phtml files (both of which are available at the book's Source Code/Download page at http://www.apress.com), which serve as the page template headers and footers, respectively. These global templates can be placed in the /application/modules/default/views/scripts/ directory and will automatically be located and integrated into the view when using the render() method. Not surprisingly, the header could include references to the page masthead as well as the CSS and JavaScript files. The footer could include things such as copyright information and the closing page tags. Tip Quite conveniently, the Zend Framework supports the ability to take advantage of more sophisticated templating solutions than those demonstrated here, such as Smarty (see Chapter 19). See the Zend Framework manual for more information.
blog comments powered by Disqus |
|
|
|
|
|
|
|