我有一个问题。 我的ZF2项目中有2个模块:Application,Search。我正在使用布局文件夹/文件。 当我使用任何Controller和Action on Application时,一切正常。当我使用搜索模块时,仅在默认操作上加载公用文件夹文件。 在其他操作上我有一个像http / mysite / search / css / mycss.css这样的网址,但我想要http / mysite / css / mycss.css。
有没有解决这个问题? 提前谢谢!
编辑:我的application.config.php
<?php
return array(
'modules' => array(
'Application',
'Feed',
'DoctrineModule',
'DoctrineMongoODMModule',
),
'module_paths' => array(
'./module',
'./vendor',
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
),
);
对不起,我的模块名为Feed not Search =)
编辑2:来自应用程序模块的路线
<?php
return array(
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'service_manager' => array(
'abstract_factories' => array(
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
'Zend\Log\LoggerAbstractServiceFactory',
),
'aliases' => array(
'translator' => 'MvcTranslator',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
'console' => array(
'router' => array(
'routes' => array(
),
),
),
);
编辑3:来自Feed模块的路线
<?php
return array(
'controllers' => array(
'invokables' => array(
'Feed\Controller\Feed' => 'Feed\Controller\FeedController',
),
),
'router' => array(
'routes' => array(
'feed' => array(
'type' => 'segment',
'options' => array(
'route' => '/feed[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]*',
),
'defaults' => array(
'controller' => 'Feed\Controller\Feed',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'feed' => __DIR__ . '/../view',
),
),
);