标题: 如何实现不同modular使用不同的layout?
wohugb
PHPEye Developer
Rank: 8Rank: 8



UID 216
精华 0
积分 0
帖子 20
翻译 0
原创 0
阅读权限 1
注册 2007-7-23
状态 离线
发表于 2008-8-1 00:20  资料  主页 短消息  加为好友  添加 wohugb 为MSN好友 通过MSN和 wohugb 交谈
如何实现不同modular使用不同的layout?

如题,我的项目中有多个模块如何实现不同的模块使用不同的layout呢?

我想前台使用一个layout,后台使用一个laylout,这个功能如何在引导文件index.php中实现呢?

谢谢各位指教!

顶部
lony
新手上路
Rank: 1



UID 1450
精华 1
积分 10
帖子 20
翻译 0
原创 1
阅读权限 10
注册 2008-7-2
状态 离线
发表于 2008-10-14 17:12  资料  短消息  加为好友 
遇到同样问题。

顶一下。

还请高手指点。

顶部
lony
新手上路
Rank: 1



UID 1450
精华 1
积分 10
帖子 20
翻译 0
原创 1
阅读权限 10
注册 2008-7-2
状态 离线
发表于 2008-10-14 18:40  资料  短消息  加为好友 
自己找答案

在Library/My/Plugin/下建立Dispatcher.php

PHP代码如下:
<?php
class MY_Plugin_Dispatcher extends Zend_Controller_Plugin_Abstract 

    public function 
preDispatch(Zend_Controller_Request_Abstract $request
    { 
        
$module $request->getModuleName(); 
        
$controller $request->getControllerName(); 
        
$action $request->getActionName(); 
         
        
$layout Zend_Layout::getMvcInstance(); 
         
        switch (
$module) { 
            case 
'index'
                
// use default layout specified in your bootstrap 
                
break; 
                 
            case 
'backend'
                
$layout->setLayout('backend'); 
                break; 
                 
            default: 
                
$layout->disableLayout(); 
                break; 
        } 
    } 
     
    public function 
postDispatch(Zend_Controller_Request_Abstract $request
    { 
    } 
}



index.php 里加上

PHP代码如下:
$frontController->registerPlugin(new MY_Plugin_Dispatcher());


还需要在你的layout文件夹下做一个backend.phtml的layout。ok,搞定。



参考:
http://dustint.com/archives/28

http://www.nabble.com/Zend-Layou ... min-td19340002.html

http://www.zfforums.com/zend-fra ... re-module-1723.html

http://framework.zend.com/manual/zh/zend.layout.options.html



[ 本帖最后由 lony 于 2008-10-14 18:49 编辑 ]

顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2009-1-10 07:08

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.300192 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver