TAILIEUCHUNG - Pro Zend Framework Techniques Build a Full CMS Project phần 3

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à 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 . 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 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 . 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

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.