Tagged Locatie: module

Zend Framework Per module Layout Instellingen - Follow Up

Door , dinsdag 16 februari 2010 20:48

Als een vervolg op mijn vorige post op per module gebaseerd layout instellingen voor Zend Framework , ik heb update van de code te verlangen minder configuratie dan voor (niet dat het nodig is meer dan een paar regels in uw toepassing configuratie!).
Continue reading 'Zend Framework Per module Layout Instellingen - Follow Up' »

Zend Framework Per-module op basis van de instellingen

Door , vrijdag 1 januari 2010 22:40

Ik heb een follow-up op dit bericht die minder configuratie vereist gemaakt, zie Module Based Layout - Zend Framework .

Bij gebruik van de Zend Framework met modules, haar duidelijk dat als u gebruik maakt van diverse (sub-) sites buiten de dezelfde toepassing die u niet per se hetzelfde willen lay-out scripts voor elk onderdeel. Ik besloot om te gaan met de volgende site structuur:

  / Toepassing
     / Controllers
         ...
     / Modellen
     / Modules
         / Default
             / Controllers
             / Lay-out
                 / Scripts
             / Uitzicht
                 / Scripts
         / AnotherModule
             ...
     / Scripts

Het probleem was het opzetten van de lay-out scripts op een per-module basis. Het antwoord kwam door het gebruik van een Action Helper. Het instellen van de lay-outs op een per-module basis bestaat uit drie stappen:

  1. Application.ini (of soortgelijke configuratie setup):
      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 / member / layouts / scripts"
     affiliate.resources.layout.layoutPath = APPLICATION_PATH "/ modules / affiliate / layouts / scripts" 
  2. Maak je Actie Helper:
      <? Php
     / **
      * Stelt de lay-out pad op een per-module basis
      *
      * @ Author Lloyd Watkin <lloyd@evilprofessor.co.uk>
      * @ Sinds 2010-01-01
      * /
     klasse Pro_Controller_Action_Helper_SetLayoutPath
         breidt Zend_Controller_Action_Helper_Abstract
     {
         / **
          * Stelt lay-out pad op basis van module
          * /
         publieke functie preDispatch ()
         {
        	 Module = $ $ this-> GetRequest () -> getModuleName ();
    
    	     if ($ bootstrap = $ this-> getActionController ()
    	                        -> GetInvokeArg ('bootstrap')) {
    
    	         $ Config = $ bootstrap-> getOptions ();
    
    	         if (isset ($ config [$ module] ['resources'] ['layout'] ['layoutPath'])) {
    	             $ LayoutPath =
    	                  $ Config [$ module] ['resources'] ['layout'] ['layoutPath'];
    	             $ This-> getActionController ()
    	                  -> GetHelper ('lay-out')
    	                  -> SetLayoutPath ($ layoutPath);
    	         }
        	 }
         }
     } 
  3. En tot slot boostrap de actie helper:
      ...
         / **
          * Stelt lay-out scripts op een per-module basis
          * /
         beschermde functie _initLayoutHelper ()
    	 {
    	     $ This-> bootstrap ('frontController');
    	     $ Layout = Zend_Controller_Action_HelperBroker:: addHelper (
    	         nieuw Pro_Controller_Action_Helper_SetLayoutPath ());
    	 }
     ... 












Panorama Thema door Themocracy

10 bezoekers online
9 gasten, 1 bots, 0 leden
Max bezoekers vandaag: 16 om 12:59 pm UTC
Deze maand: 19 op 19-08-2011 06:09 GMT
Dit jaar: 130 op 28-03-2011 22:40 GMT
All time: 130 op 28-03-2011 22:40 GMT