tailieunhanh - Practical Web 2.0 Applications with PHP phần 2

9. Thay đổi các đối số phương pháp settable () bằng cách thêm 0 như là đối số thứ hai như thế này: $ xml-settable (blog ', 0) 10. Lưu trang, và thử nghiệm nó một lần nữa. Lần này, Lưu , và tải nó vào một trình duyệtVí dụ 4-22 cho thấy các nội dung của người dùng | Simpo PDF Merge and Split Unregistered Version - http CHAPTER 2 SETTING UP THE APPLICATION FRAMEWORK 39 Integrating Smarty with the Web Site Controllers Finally we need to make Zend_Controller use the Templater class instead of its default Zend_View class. To do this we must use the following code which we will shortly add to the application bootstrap file vr new Zend_Controller_Action_Helper_ViewRenderer vr- setView new Templater vr- setViewSuffix tpl Zend_Controller_Action_HelperBroker addHelper vr Note that we must call setViewSuffix to indicate that templates finish with a file extension of .tpl. By default Zend_View will use the extension .phtml. Listing 2-12 shows how the controller part of looks once this code has been added. Listing 2-12. TellingZend_Controller to Use Smarty Instead of its Default View Renderer php . other code handle the user request controller Zend_Controller_Front getInstance controller- setControllerDirectory config- paths- base . include Controllers setup the view renderer vr new Zend_Controller_Action_Helper_ViewRenderer vr- setView new Templater vr- setViewSuffix tpl Zend_Controller_Action_HelperBroker addHelper vr controller- dispatch Note Viewing the web site now will still display the Web site home message. However a Smarty error will occur since we haven t yet created the corresponding template file for the index action of the index controller. Now whenever a controller action is executed Zend_Controller will automatically look for a template based on the controller and action name. Let s use the index action of the index controller as an example as shown in Listing 2-13. Simpo PDF Merge and Split Unregistered Version - http 40 CHAPTER 2 SETTING UP THE APPLICATION FRAMEWORK Listing 2-13. Our New Index Controller Now Outputting the File php class Indexcontroller extends CustomControllerAction public function indexAction When you open http phpweb20