Warning: fopen(/homepages/30/d192847469/htdocs/evilprofessor.co.uk/public_html/wp-content/gt-cache/vi/_vi_tag_layoutpath) [function.fopen]: failed to open stream: Disk quota exceeded in /homepages/30/d192847469/htdocs/evilprofessor.co.uk/public_html/wp-content/plugins/global-translator/translator.php on line 1183

Warning: flock() expects parameter 1 to be resource, boolean given in /homepages/30/d192847469/htdocs/evilprofessor.co.uk/public_html/wp-content/plugins/global-translator/translator.php on line 1184

Warning: fwrite(): supplied argument is not a valid stream resource in /homepages/30/d192847469/htdocs/evilprofessor.co.uk/public_html/wp-content/plugins/global-translator/translator.php on line 1188

Warning: fclose(): supplied argument is not a valid stream resource in /homepages/30/d192847469/htdocs/evilprofessor.co.uk/public_html/wp-content/plugins/global-translator/translator.php on line 1190
Evilprofessor.co.uk »layoutPath

Bài viết được gắn thẻ: layoutPath

Zend Framework Per-Module dựa trên thiết lập

Bình luận (8)
, Thứ Sáu ngày 1 Tháng 1 2010 22:40

Tôi đã tạo ra một followup bài đăng này đòi hỏi cấu hình ít hơn, xin vui lòng xem Giao diện dựa trên module - Zend Framework .

Khi sử dụng khuôn khổ zend với các mô-đun, rằng nếu bạn đang chạy khác nhau (phụ) các trang web off cùng một ứng dụng, bạn không nhất thiết muốn cùng một kịch bản bố trí cho từng phần rõ ràng của nó . Tôi quyết định đi với cấu trúc trang web sau đây:

  / Ứng dụng
     / Bộ điều khiển
         ...
     / Mô hình
     / Modules
         / Mặc định
             / Bộ điều khiển
             / Bố trí
                 / Scripts
             / Views
                 / Scripts
         / AnotherModule
             ...
     / Scripts

Vấn đề đã được thiết lập các kịch bản bố trí trên một cơ sở cho mỗi mô-đun. Câu trả lời đến thông qua việc sử dụng một người trợ giúp hành động. Thiết lập bố trí trên một cơ sở cho mỗi mô-đun bao gồm ba bước:

  1. Application.ini (hoặc tương tự thiết lập cấu hình):
      admin.resources.layout.layoutPath = APPLICATION_PATH / modules / admin / layouts / scripts "
     default.resources.layout.layoutPath = APPLICATION_PATH "/ modules / default / layouts / scripts"
     member.resources.layout.layoutPath = APPLICATION_PATH "/ modules / thành viên / layouts / scripts"
     affiliate.resources.layout.layoutPath = APPLICATION_PATH "/ modules / liên kết / layouts / scripts" 
  2. Tạo người trợ giúp hành động của bạn:
      <? Php
     / **
      * Thiết lập đường dẫn bố trí trên một cơ sở cho mỗi mô-đun
      *
      * @ Tác giả Lloyd Watkin <lloyd@evilprofessor.co.uk>
      * @ Kể từ 2010/01/01
      * /
     lớp Pro_Controller_Action_Helper_SetLayoutPath
         mở rộng Zend_Controller_Action_Helper_Abstract
     {
         / **
          * Bộ bố trí đường dẫn dựa trên mô-đun
          * /
         public function preDispatch ()
         {
        	 $ Module = $ this-> getRequest () -> getModuleName ();
    
    	     nếu ($ bootstrap = $ this-> getActionController ()
    	                        -> GetInvokeArg (bootstrap ')) {
    
    	         $ Config = $ bootstrap-> getOptions ();
    
    	         if (isset ($ config [$ mô-đun] ['nguồn lực'] ['bố trí'] ['layoutPath'])) {
    	             $ LayoutPath =
    	                  $ Config [Module] ['nguồn lực'] ['bố trí'] ['layoutPath'];
    	             $ This-> getActionController ()
    	                  -> GetHelper ('bố trí')
    	                  -> SetLayoutPath ($ layoutPath);
    	         }
        	 }
         }
     } 
  3. Và cuối cùng boostrap các helper hành động:
     ...  / *** Thiết lập các kịch bản bố trí trên một cơ sở cho mỗi mô-đun * / bảo vệ chức năng _initLayoutHelper () {$ this-> tải và khởi động hệ điều hành ('frontController); bố trí = Zend_Controller_Action_HelperBroker :: addHelper (Pro_Controller_Action_Helper_SetLayoutPath mới ());} ... . 












Panorama Theme theo Themocracy

6 khách truy cập trực tuyến tại
4 khách, 2 chương trình, 0 thành viên
Max khách truy cập hôm nay: 13 lúc 09:36 am UTC
Tháng này: 40 23-05-2012 03:33 am UTC
Năm nay: 69 27-02-2012 09:56 am UTC
Tất cả thời gian: 130 28-03-2011 10:40 pm UTC