Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Trước tiên, để tạo ra loadSkin () helper xem, bạn cần để tạo ra các lớp học. Thêm một tập tin mới để ứng dụng / views / người giúp việc tên là LoadSkin.php Tiếp theo, mở tập tin này, và thêm các lớp học dành cho trợ giúp của bạn. Tên lớp nên được Zend_View_Helper_LoadSkin, và nó nên mở rộng | CHAPTER 2 DESIGNING YOUR SITE Zend_View_Helper_Abstract Your class should extend the Zend_View_Helper_Abstract base class. First to create the loadSkin view helper you need to create the class. Add a new file to application views helpers named LoadSkin.php. Next open this file and add the class for your helper. The class name should be Zend_View_Helper_LoadSkin and it should extend Zend_View_Helper_Abstract. Then create the constructor method loadSkin which you need to be able to pass the skin that you want to load to. The helper will load the config file for this skin and then add each of the style sheets that are specified to the view headLink placeholder as shown in Listing 2-13. Listing2-13. TheloadSkin Class in application views helpers LoadSkin.php php this class loads the cms skin class Zend_View_Helper_LoadSkin extends Zend_View_Helper_Abstract public function loadSkin skin _ load the skin config file skinData new Zend_Config_Xml . skins . skin . skin.xml stylesheets skinData- stylesheets- stylesheet- toArray append each stylesheet if is_array stylesheets foreach stylesheets as stylesheet this- view- headLink - appendStylesheet skins . skin . css . stylesheet Using the loadSkin Helper The loadSkin helper requires that you pass it a valid skin. You could set this skin setting in the layout script when you call the helper but this can make your CMS less flexible ideally you should be able to switch the skins without touching the layout file. You may want to do something more dynamic in the future but for now it makes sense to set the skin while you are bootstrapping the application. As I mentioned in the first chapter Zend_Application initializes the front controller by default which in turn initializes Zend_View. This default behavior is sufficient most of the time but in this case you need more control over the process. To get this control you can initialize the view yourself and then set the view object manually. The first thing you need to do is create a