各位高人..本人在开始用ZF做一个项目...我分二个模块...第一个是前台(default).另一个是后台(admin).
我在前台页面有一个链接到后台的动作...比如说..我在aaa.php这个页面里有这么一个动作..当我点链接的时候.他可以进入到后台(admin)的(bbb.php)页面....(也就是证明了路由分发到了这个控制器并产生了index这个动作).可是当我点击bbb.php页面上的链接(这里的链接是admin这个模块里,存在的控制器上的都存在的动作)时候.就会显示出aaa.php 的页面....不知道是怎么一回事..下面贴我的index.php文件出来..哎...好晕...希望有高手帮小弟一把...
<?php
error_reporting(E_ALL|E_STRICT);
//date_default_timezone_get('Asia/Shanghai');
date_default_timezone_set('Asia/Shanghai');
define('ROOT','../shop/');//定义网站根目录
define('DIR_STYLE',ROOT.'public/styles/');//定义样式目录
set_include_path( '.'. PATH_SEPARATOR .
'./library/'. PATH_SEPARATOR .
'./application/modules/default/models/'. PATH_SEPARATOR .
get_include_path());
require_once 'Smarty/Smarty.class.php';
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload(); //自动加载类文件
$registry = Zend_Registry::getInstance(); //实例化注册对象
/*网站主文件SMARTY配置文件*/
$smarty=new Smarty();
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$smarty->compile_dir="./application/modules/default/views/templates_c";
$smarty->template_dir="./application/modules/default/views/templates";
$registry['smarty']=$smarty;
/*后台管理员SMARTY配置文件*/
$smart=new Smarty();
$smart->left_delimiter="<{";
$smart->right_delimiter="}>";
$smart->compile_dir="./application/modules/admin/views/templates_c";
$smart->template_dir="./application/modules/admin/views/templates";
$registry['smart']=$smart;
//读取配置文件
require_once 'Zend/Config/Ini.php';
$config=new Zend_Config_Ini('./application/config/config.ini','general');
$registry['config']=$config;
//连接到数据库
$db=Zend_Db::factory($config->db->type,$config->db->config->toArray());
Zend_Db_Table::setDefaultAdapter($db);
$registry['db']=$db;
$auth=Zend_Auth::getInstance();//实例化用户认证类
$acl=new ShopAcl();//实例化用户权限类
//首先通过getInstance()获取前端控制器实例,然后通过setControllerDirectory() 注册传入的路径,最后分发.
$frontController = Zend_Controller_Front::getInstance();
//取到控制器目录的当前位置
$frontController->addModuleDirectory('./application/modules')
->setBaseUrl('/shop')//设置基地址
->setParam('useDefaultControllerAlways',true)//缺省或者错误控制器时使用默认控制器
->setParam('noViewRenderer',true)//禁止自动动视图渲染
->setParam('noErrorHandler',true)//禁止自动错误处理
->throwExceptions(true)
->registerPlugin(new ShopAuth($auth,$acl))
->dispatch();