1

我有问题。我的 ZF2 项目中有 2 个模块:应用程序、搜索。我正在使用布局文件夹/文件。当我在应用程序上使用任何控制器和操作时,一切正常。当我使用搜索模块时,仅在默认操作上加载公用文件夹文件。在其他操作中,我有一个类似 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',
        ),
    ),
);
4

0 回答 0