Ver Mensaje Individual
  #9 (permalink)  
Antiguo 19/06/2011, 12:27
phpdevelopment
 
Fecha de Ingreso: mayo-2011
Mensajes: 256
Antigüedad: 13 años
Puntos: 5
Respuesta: Archivo .ini por modulo

Ya parece que funciona , aunque la idea principal , era para poder hacer un layout para cada modulo.
Ahora el problema es el siguiente.

Esta clase me genera un layout para cada modulo

Código PHP:
class My_Layout extends Zend_Controller_Plugin_Abstract {

    
/**
     * Array of layout paths associating modules with layouts
     */
    
protected $_moduleLayouts;

    
/**
     * Registers a module layout.
     * This layout will be rendered when the specified module is called.
     * If there is no layout registered for the current module, the default layout as specified
     * in Zend_Layout will be rendered
     *
     * @param String $module        The name of the module
     * @param String $layoutPath    The path to the layout
     * @param String $layout        The name of the layout to render
     */
    
public function registerModuleLayout($module$layoutPath$layout=null){
        
$this->_moduleLayouts[$module] = array(
            
'layoutPath' => $layoutPath,
            
'layout' => $layout
        
);
  }

    public function 
preDispatch(Zend_Controller_Request_Abstract $request){
        if(isset(
$this->_moduleLayouts[$request->getModuleName()])){
            
$config $this->_moduleLayouts[$request->getModuleName()];


            
$layout Zend_Layout::getMvcInstance();
            if(
$layout->getMvcEnabled()){
                
$layout->setLayoutPath($config['layoutPath']);

                if(
$config['layout'] !== null){
                    
$layout->setLayout($config['layout']);
                }
            }
        }
    }


Mi .ini es el siguiente.el del general

Código PHP:
[production]
phpSettings.display_startup_errors 0
phpSettings
.display_errors 0
includePaths
.library APPLICATION_PATH "/../library"
bootstrap.path APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace "Application"
resources.frontController.controllerDirectory APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions 0


resources
.frontController.moduleDirectory APPLICATION_PATH "/modules"
resources.modules[] = ""


 
autoloaderNamespaces[] = "My_"

[staging production]

[
testing production]
phpSettings.display_startup_errors 1
phpSettings
.display_errors 1

[development production]
phpSettings.display_startup_errors 1
phpSettings
.display_errors 1
resources
.frontController.params.displayExceptions 
el ini del modulo admi es
Código PHP:
[production]


resources.layout.layout "admin"
resources.layout.layoutPath APPLICATION_PATH "/modules/admin/layouts"


[staging production]

[
testing production]
phpSettings.display_startup_errors 1
phpSettings
.display_errors 1

[development production]
phpSettings.display_startup_errors 1
phpSettings
.display_errors 1
resources
.frontController.params.displayExceptions 
Y el layout que esta en admin. es el siguiente.

Código PHP:
<?php echo $this->doctype(); ?>
<html>
<head>
</head>
<body>
<div class="header">
</div>
<div class="content">

<?php echo $this->layout()->content?>
</div>
<div class="footer">
</div>
</body>
</html>
Pues la salida del html es:
Código HTML:
<html><head></head><body>Esto es el admin</body></html> 
Cuando deberia ser:

Código HTML:
<html><head></head><body><div class="header">
</div>
<div class="content">
Esto es el admin</body></html>
</div>
<div class="footer">
</div> 
Sabes a que se puede deber este error, se me escapa algo....

Última edición por phpdevelopment; 19/06/2011 a las 12:28 Razón: actualizar