Php Zend Framework 2动态路由

Php Zend Framework 2动态路由,php,zend-framework,frameworks,zend-framework2,Php,Zend Framework,Frameworks,Zend Framework2,我现在正在尝试Zend Framework 2,但在路由方面遇到了一些问题。我有这样一个导航: Home Current News Schedule Club History Management Referee Restaurant Team First Table Squad Second Table Squad Old Table

我现在正在尝试Zend Framework 2,但在路由方面遇到了一些问题。我有这样一个导航:

Home
Current
    News
    Schedule
Club
    History
    Management
    Referee
    Restaurant
Team
    First
        Table
        Squad
    Second
        Table
        Squad
    Old
        Table
        Squad
    Djunior
        Table
        Squad
    Efjunior
        Table
        Squad
    National
        Table
        Squad
    Utility
        Table
        Squad
Sponsor
About
    Approach
    Contact
    Disclaimer
    Imprint
return array(
    'router' => array(
        'routes' => array(
            //Literal-Route: Home
            //Controller: IndexController
            //View: index/index.phtml
            'home' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'Football\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
            ),
            //Segment-Route: football
            'football' => 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(
                        '__NAMESPACE__' => 'Football\Controller',
                        'controller' => 'index',
                        'action'     => 'index',
                    ),
                ),
            ),
            'subteam' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'    => '[/:controller[[/first]/:action]]',
                    'constraints' => array(
                        'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                    ),
                    'defaults' => array(
                        '__NAMESPACE__' => 'Football\Controller',
                        'controller' => 'index',
                        'action'     => 'index',
                    ),
                ),  
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Football\Controller\Index' => 'Football\Controller\IndexController',
            'Football\Controller\Current' => 'Football\Controller\CurrentController',
            'Football\Controller\About' => 'Football\Controller\AboutController',
            'Football\Controller\Sponsor' => 'Football\Controller\SponsorController',
            'Football\Controller\Club' => 'Football\Controller\ClubController',
            'Football\Controller\Team' => 'Football\Controller\TeamController',
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
            'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
        ),
    ),
    'translator' => array(
        'locale' => 'en_US',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'navigation' => array(
        'default' => array(
            //localhost
            array(
                'label' => 'Home',
                'route' => 'home',
            ),
            //localhost/current
            'current' => array(
                'type'       => 'mvc',
                'order'      => '100',
                'label'      => 'Aktuelles',
                'route'      => 'football',
                'controller' => 'current',
                'action'     => 'index',
                'pages' => array(
                    //localhost/current/news
                    'news' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => 'Nachrichten',
                        'route'      => 'football',
                        'controller' => 'current',
                        'action'     => 'news',
                    ),
                    //localhost/current/schedule
                    'schedule' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => 'Trainingszeiten',
                        'route'      => 'football',
                        'controller' => 'current',
                        'action'     => 'schedule',
                    ),
                ),
            ),
            //localhost/club
            'club' => array(
                'type'       => 'mvc',
                'order'      => '200',
                'label'      => 'Verein',
                'route'      => 'football',
                'controller' => 'club',
                'action'     => 'index',
                'pages' => array(
                //localhost/club/history
                    'history' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => 'Geschichte',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'history',
                    ),
                    //localhost/club/management
                    'management' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => 'Vorstand',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'management',
                    ),
                    //localhost/club/referee
                    'referee' => array(
                        'type'       => 'mvc',
                        'order'      => '300',
                        'label'      => 'Schiedsrichter',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'referee',
                    ),
                    //localhost/club/restaurant
                    'restaurant' => array(
                        'type'       => 'mvc',
                        'order'      => '400',
                        'label'      => 'Gaststätte',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'restaurant',
                    ),
                ),
            ),
            //localhost/team
            'team' => array(
                'type'       => 'mvc',
                'order'      => '300',
                'label'      => 'Mannschaften',
                'route'      => 'football',
                'controller' => 'team',
                'action'     => 'index',
                'pages' => array(
                //localhost/team/first
                    'first' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => '1. Herren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'first',
                        'pages' => array(
                            //localhost/team/first/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/first/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/second
                    'second' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => '2. Herren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'second',
                        'pages' => array(
                            //localhost/team/second/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/second/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/old
                    'old' => array(
                        'type'       => 'mvc',
                        'order'      => '300',
                        'label'      => 'Alte Herren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'old',
                        'pages' => array(
                            //localhost/team/old/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/old/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/djunior
                    'djunior' => array(
                        'type'       => 'mvc',
                        'order'      => '400',
                        'label'      => 'D-Junioren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'djunior',
                        'pages' => array(
                            //localhost/team/djunior/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/djunior/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/efjunior
                    'efjunior' => array(
                        'type'       => 'mvc',
                        'order'      => '500',
                        'label'      => 'E/F-Junioren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'efjunior',
                        'pages' => array(
                            //localhost/team/efjunior/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/efjunior/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/national/
                    'national' => array(
                        'type'       => 'mvc',
                        'order'      => '600',
                        'label'      => 'Volkssport',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'national',
                        'pages' => array(
                            //localhost/team/national/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/national/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/utility/
                    'utility' => array(
                        'type'       => 'mvc',
                        'order'      => '700',
                        'label'      => 'Stadtwerke',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'utility',
                        'pages' => array(
                            //localhost/team/utility/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/utility/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                ),
            ),
            //localhost/sponsor
            'sponsor' => array(
                'type'       => 'mvc',
                'order'      => '400',
                'label'      => 'Sponsoren',
                'route'      => 'football',
                'controller' => 'sponsor',
                'action'     => 'index',
            ),
            //localhost/about
            'about' => array(
                'type'       => 'mvc',
                'order'      => '500',
                'label'      => 'Über uns',
                'route'      => 'football',
                'controller' => 'about',
                'action'     => 'index',
                'pages' => array(
                    //localhost/about/approach
                    'approach' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => 'Anfahrt',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'approach',
                    ),
                    //localhost/about/contact
                    'contact' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => 'Kontakt',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'contact',
                    ),
                    //localhost/about/disclaimer
                    'disclaimer' => array(
                        'type'       => 'mvc',
                        'order'      => '300',
                        'label'      => 'Disclaimer',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'disclaimer',
                    ),
                    //localhost/about/imprint
                    'imprint' => array(
                        'type'       => 'mvc',
                        'order'      => '400',
                        'label'      => 'Impressum',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'imprint',
                    ),
                ),
            ),
        ),
    ),                                              
    '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',
            'layout/header'        => __DIR__ . '/../view/layout/header.phtml',
            'layout/sidebar'        => __DIR__ . '/../view/layout/sidebar.phtml',
            'layout/footer'        => __DIR__ . '/../view/layout/footer.phtml',
            'football/index/index' => __DIR__ . '/../view/football/index/index.phtml',
            'error/404'            => __DIR__ . '/../view/error/404.phtml',
            'error/index'          => __DIR__ . '/../view/error/index.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
);
我的module.config.php如下所示:

Home
Current
    News
    Schedule
Club
    History
    Management
    Referee
    Restaurant
Team
    First
        Table
        Squad
    Second
        Table
        Squad
    Old
        Table
        Squad
    Djunior
        Table
        Squad
    Efjunior
        Table
        Squad
    National
        Table
        Squad
    Utility
        Table
        Squad
Sponsor
About
    Approach
    Contact
    Disclaimer
    Imprint
return array(
    'router' => array(
        'routes' => array(
            //Literal-Route: Home
            //Controller: IndexController
            //View: index/index.phtml
            'home' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'Football\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
            ),
            //Segment-Route: football
            'football' => 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(
                        '__NAMESPACE__' => 'Football\Controller',
                        'controller' => 'index',
                        'action'     => 'index',
                    ),
                ),
            ),
            'subteam' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'    => '[/:controller[[/first]/:action]]',
                    'constraints' => array(
                        'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                    ),
                    'defaults' => array(
                        '__NAMESPACE__' => 'Football\Controller',
                        'controller' => 'index',
                        'action'     => 'index',
                    ),
                ),  
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Football\Controller\Index' => 'Football\Controller\IndexController',
            'Football\Controller\Current' => 'Football\Controller\CurrentController',
            'Football\Controller\About' => 'Football\Controller\AboutController',
            'Football\Controller\Sponsor' => 'Football\Controller\SponsorController',
            'Football\Controller\Club' => 'Football\Controller\ClubController',
            'Football\Controller\Team' => 'Football\Controller\TeamController',
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
            'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
        ),
    ),
    'translator' => array(
        'locale' => 'en_US',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'navigation' => array(
        'default' => array(
            //localhost
            array(
                'label' => 'Home',
                'route' => 'home',
            ),
            //localhost/current
            'current' => array(
                'type'       => 'mvc',
                'order'      => '100',
                'label'      => 'Aktuelles',
                'route'      => 'football',
                'controller' => 'current',
                'action'     => 'index',
                'pages' => array(
                    //localhost/current/news
                    'news' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => 'Nachrichten',
                        'route'      => 'football',
                        'controller' => 'current',
                        'action'     => 'news',
                    ),
                    //localhost/current/schedule
                    'schedule' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => 'Trainingszeiten',
                        'route'      => 'football',
                        'controller' => 'current',
                        'action'     => 'schedule',
                    ),
                ),
            ),
            //localhost/club
            'club' => array(
                'type'       => 'mvc',
                'order'      => '200',
                'label'      => 'Verein',
                'route'      => 'football',
                'controller' => 'club',
                'action'     => 'index',
                'pages' => array(
                //localhost/club/history
                    'history' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => 'Geschichte',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'history',
                    ),
                    //localhost/club/management
                    'management' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => 'Vorstand',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'management',
                    ),
                    //localhost/club/referee
                    'referee' => array(
                        'type'       => 'mvc',
                        'order'      => '300',
                        'label'      => 'Schiedsrichter',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'referee',
                    ),
                    //localhost/club/restaurant
                    'restaurant' => array(
                        'type'       => 'mvc',
                        'order'      => '400',
                        'label'      => 'Gaststätte',
                        'route'      => 'football',
                        'controller' => 'club',
                        'action'     => 'restaurant',
                    ),
                ),
            ),
            //localhost/team
            'team' => array(
                'type'       => 'mvc',
                'order'      => '300',
                'label'      => 'Mannschaften',
                'route'      => 'football',
                'controller' => 'team',
                'action'     => 'index',
                'pages' => array(
                //localhost/team/first
                    'first' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => '1. Herren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'first',
                        'pages' => array(
                            //localhost/team/first/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/first/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/second
                    'second' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => '2. Herren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'second',
                        'pages' => array(
                            //localhost/team/second/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/second/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/old
                    'old' => array(
                        'type'       => 'mvc',
                        'order'      => '300',
                        'label'      => 'Alte Herren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'old',
                        'pages' => array(
                            //localhost/team/old/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/old/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/djunior
                    'djunior' => array(
                        'type'       => 'mvc',
                        'order'      => '400',
                        'label'      => 'D-Junioren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'djunior',
                        'pages' => array(
                            //localhost/team/djunior/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/djunior/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/efjunior
                    'efjunior' => array(
                        'type'       => 'mvc',
                        'order'      => '500',
                        'label'      => 'E/F-Junioren',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'efjunior',
                        'pages' => array(
                            //localhost/team/efjunior/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/efjunior/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/national/
                    'national' => array(
                        'type'       => 'mvc',
                        'order'      => '600',
                        'label'      => 'Volkssport',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'national',
                        'pages' => array(
                            //localhost/team/national/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/national/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                    //localhost/team/utility/
                    'utility' => array(
                        'type'       => 'mvc',
                        'order'      => '700',
                        'label'      => 'Stadtwerke',
                        'route'      => 'football',
                        'controller' => 'team',
                        'action'     => 'utility',
                        'pages' => array(
                            //localhost/team/utility/table
                            'table' => array(
                                'type'       => 'mvc',
                                'order'      => '100',
                                'label'      => 'Tabelle',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'table',
                            ),
                            //localhost/team/utility/squad
                            'squad' => array(
                                'type'       => 'mvc',
                                'order'      => '200',
                                'label'      => 'Mannschaftskader',
                                'route'      => 'subteam',
                                'controller' => 'team',
                                'action'     => 'squad',
                            ),
                        ),
                    ),
                ),
            ),
            //localhost/sponsor
            'sponsor' => array(
                'type'       => 'mvc',
                'order'      => '400',
                'label'      => 'Sponsoren',
                'route'      => 'football',
                'controller' => 'sponsor',
                'action'     => 'index',
            ),
            //localhost/about
            'about' => array(
                'type'       => 'mvc',
                'order'      => '500',
                'label'      => 'Über uns',
                'route'      => 'football',
                'controller' => 'about',
                'action'     => 'index',
                'pages' => array(
                    //localhost/about/approach
                    'approach' => array(
                        'type'       => 'mvc',
                        'order'      => '100',
                        'label'      => 'Anfahrt',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'approach',
                    ),
                    //localhost/about/contact
                    'contact' => array(
                        'type'       => 'mvc',
                        'order'      => '200',
                        'label'      => 'Kontakt',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'contact',
                    ),
                    //localhost/about/disclaimer
                    'disclaimer' => array(
                        'type'       => 'mvc',
                        'order'      => '300',
                        'label'      => 'Disclaimer',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'disclaimer',
                    ),
                    //localhost/about/imprint
                    'imprint' => array(
                        'type'       => 'mvc',
                        'order'      => '400',
                        'label'      => 'Impressum',
                        'route'      => 'football',
                        'controller' => 'about',
                        'action'     => 'imprint',
                    ),
                ),
            ),
        ),
    ),                                              
    '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',
            'layout/header'        => __DIR__ . '/../view/layout/header.phtml',
            'layout/sidebar'        => __DIR__ . '/../view/layout/sidebar.phtml',
            'layout/footer'        => __DIR__ . '/../view/layout/footer.phtml',
            'football/index/index' => __DIR__ . '/../view/football/index/index.phtml',
            'error/404'            => __DIR__ . '/../view/error/404.phtml',
            'error/index'          => __DIR__ . '/../view/error/index.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
);
我认为我现在的问题是子团队路线,因为它是静态的,所以当我点击例如团队->第二->表格时,路线将是“团队->第一->表格”。不管我点击哪个团队,这个“第一”部分总是在那里,我不知道如何动态地创建它。希望你们能理解,有人能清楚地向我解释,如何动态地制定这些团队路线。:)

编辑:我更新了module.config.php,您现在可以看到整个文件了

AboutController.php

namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AboutController extends AbstractActionController
{
 public function indexAction()
{
     return new ViewModel();
 }

public function contactAction()
{
    return new ViewModel();
 }

public function approachAction()
{
     return new ViewModel();
 }

 public function disclaimerAction()
{
     return new ViewModel();
 }

public function imprintAction()
 {
     return new ViewModel();
 }
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class ClubController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function historyAction()
{
    return new ViewModel();
 }

public function managementAction()
 {
    return new ViewModel();
 }

 public function refereeAction()
 {
    return new ViewModel();
 }

public function restaurantAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class CurrentController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function newsAction()
{
    return new ViewModel();
}

public function scheduleAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function clubAction()
{
    return new ViewModel();
}

public function contactAction()
{
    return new ViewModel();
}

public function currentAction()
{
    return new ViewModel();
}

public function teamAction()
{
    return new ViewModel();
}

public function sponsorAction()
{
    return new ViewModel();
}

public function approachAction()
{
    return new ViewModel();
}

public function imprintAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class SponsorController extends AbstractActionController
{
public function indexAction()
{
    //DatenbankAdapter holen
    $db = $this->getServiceLocator()->get('db');

    return new ViewModel(array('db' => $db));
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class TeamController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function firstAction()
{
    return new ViewModel();
}

public function tableAction()
{
    return new ViewModel();
}

public function squadAction()
{
    return new ViewModel();
}

public function secondAction()
{
    return new ViewModel();
}

public function oldAction()
{
    return new ViewModel();
}

public function djuniorAction()
{
    return new ViewModel();
}

public function efjuniorAction()
{
    return new ViewModel();
}

public function nationalAction()
{
    return new ViewModel();
}

public function utilityAction()
{
    return new ViewModel();
}
ClubController.php

namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AboutController extends AbstractActionController
{
 public function indexAction()
{
     return new ViewModel();
 }

public function contactAction()
{
    return new ViewModel();
 }

public function approachAction()
{
     return new ViewModel();
 }

 public function disclaimerAction()
{
     return new ViewModel();
 }

public function imprintAction()
 {
     return new ViewModel();
 }
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class ClubController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function historyAction()
{
    return new ViewModel();
 }

public function managementAction()
 {
    return new ViewModel();
 }

 public function refereeAction()
 {
    return new ViewModel();
 }

public function restaurantAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class CurrentController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function newsAction()
{
    return new ViewModel();
}

public function scheduleAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function clubAction()
{
    return new ViewModel();
}

public function contactAction()
{
    return new ViewModel();
}

public function currentAction()
{
    return new ViewModel();
}

public function teamAction()
{
    return new ViewModel();
}

public function sponsorAction()
{
    return new ViewModel();
}

public function approachAction()
{
    return new ViewModel();
}

public function imprintAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class SponsorController extends AbstractActionController
{
public function indexAction()
{
    //DatenbankAdapter holen
    $db = $this->getServiceLocator()->get('db');

    return new ViewModel(array('db' => $db));
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class TeamController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function firstAction()
{
    return new ViewModel();
}

public function tableAction()
{
    return new ViewModel();
}

public function squadAction()
{
    return new ViewModel();
}

public function secondAction()
{
    return new ViewModel();
}

public function oldAction()
{
    return new ViewModel();
}

public function djuniorAction()
{
    return new ViewModel();
}

public function efjuniorAction()
{
    return new ViewModel();
}

public function nationalAction()
{
    return new ViewModel();
}

public function utilityAction()
{
    return new ViewModel();
}
CurrentController.php

namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AboutController extends AbstractActionController
{
 public function indexAction()
{
     return new ViewModel();
 }

public function contactAction()
{
    return new ViewModel();
 }

public function approachAction()
{
     return new ViewModel();
 }

 public function disclaimerAction()
{
     return new ViewModel();
 }

public function imprintAction()
 {
     return new ViewModel();
 }
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class ClubController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function historyAction()
{
    return new ViewModel();
 }

public function managementAction()
 {
    return new ViewModel();
 }

 public function refereeAction()
 {
    return new ViewModel();
 }

public function restaurantAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class CurrentController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function newsAction()
{
    return new ViewModel();
}

public function scheduleAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function clubAction()
{
    return new ViewModel();
}

public function contactAction()
{
    return new ViewModel();
}

public function currentAction()
{
    return new ViewModel();
}

public function teamAction()
{
    return new ViewModel();
}

public function sponsorAction()
{
    return new ViewModel();
}

public function approachAction()
{
    return new ViewModel();
}

public function imprintAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class SponsorController extends AbstractActionController
{
public function indexAction()
{
    //DatenbankAdapter holen
    $db = $this->getServiceLocator()->get('db');

    return new ViewModel(array('db' => $db));
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class TeamController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function firstAction()
{
    return new ViewModel();
}

public function tableAction()
{
    return new ViewModel();
}

public function squadAction()
{
    return new ViewModel();
}

public function secondAction()
{
    return new ViewModel();
}

public function oldAction()
{
    return new ViewModel();
}

public function djuniorAction()
{
    return new ViewModel();
}

public function efjuniorAction()
{
    return new ViewModel();
}

public function nationalAction()
{
    return new ViewModel();
}

public function utilityAction()
{
    return new ViewModel();
}
IndexController.php

namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AboutController extends AbstractActionController
{
 public function indexAction()
{
     return new ViewModel();
 }

public function contactAction()
{
    return new ViewModel();
 }

public function approachAction()
{
     return new ViewModel();
 }

 public function disclaimerAction()
{
     return new ViewModel();
 }

public function imprintAction()
 {
     return new ViewModel();
 }
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class ClubController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function historyAction()
{
    return new ViewModel();
 }

public function managementAction()
 {
    return new ViewModel();
 }

 public function refereeAction()
 {
    return new ViewModel();
 }

public function restaurantAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class CurrentController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function newsAction()
{
    return new ViewModel();
}

public function scheduleAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function clubAction()
{
    return new ViewModel();
}

public function contactAction()
{
    return new ViewModel();
}

public function currentAction()
{
    return new ViewModel();
}

public function teamAction()
{
    return new ViewModel();
}

public function sponsorAction()
{
    return new ViewModel();
}

public function approachAction()
{
    return new ViewModel();
}

public function imprintAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class SponsorController extends AbstractActionController
{
public function indexAction()
{
    //DatenbankAdapter holen
    $db = $this->getServiceLocator()->get('db');

    return new ViewModel(array('db' => $db));
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class TeamController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function firstAction()
{
    return new ViewModel();
}

public function tableAction()
{
    return new ViewModel();
}

public function squadAction()
{
    return new ViewModel();
}

public function secondAction()
{
    return new ViewModel();
}

public function oldAction()
{
    return new ViewModel();
}

public function djuniorAction()
{
    return new ViewModel();
}

public function efjuniorAction()
{
    return new ViewModel();
}

public function nationalAction()
{
    return new ViewModel();
}

public function utilityAction()
{
    return new ViewModel();
}
SponsorController.php

namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AboutController extends AbstractActionController
{
 public function indexAction()
{
     return new ViewModel();
 }

public function contactAction()
{
    return new ViewModel();
 }

public function approachAction()
{
     return new ViewModel();
 }

 public function disclaimerAction()
{
     return new ViewModel();
 }

public function imprintAction()
 {
     return new ViewModel();
 }
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class ClubController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function historyAction()
{
    return new ViewModel();
 }

public function managementAction()
 {
    return new ViewModel();
 }

 public function refereeAction()
 {
    return new ViewModel();
 }

public function restaurantAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class CurrentController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function newsAction()
{
    return new ViewModel();
}

public function scheduleAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function clubAction()
{
    return new ViewModel();
}

public function contactAction()
{
    return new ViewModel();
}

public function currentAction()
{
    return new ViewModel();
}

public function teamAction()
{
    return new ViewModel();
}

public function sponsorAction()
{
    return new ViewModel();
}

public function approachAction()
{
    return new ViewModel();
}

public function imprintAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class SponsorController extends AbstractActionController
{
public function indexAction()
{
    //DatenbankAdapter holen
    $db = $this->getServiceLocator()->get('db');

    return new ViewModel(array('db' => $db));
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class TeamController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function firstAction()
{
    return new ViewModel();
}

public function tableAction()
{
    return new ViewModel();
}

public function squadAction()
{
    return new ViewModel();
}

public function secondAction()
{
    return new ViewModel();
}

public function oldAction()
{
    return new ViewModel();
}

public function djuniorAction()
{
    return new ViewModel();
}

public function efjuniorAction()
{
    return new ViewModel();
}

public function nationalAction()
{
    return new ViewModel();
}

public function utilityAction()
{
    return new ViewModel();
}
TeamController.php

namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AboutController extends AbstractActionController
{
 public function indexAction()
{
     return new ViewModel();
 }

public function contactAction()
{
    return new ViewModel();
 }

public function approachAction()
{
     return new ViewModel();
 }

 public function disclaimerAction()
{
     return new ViewModel();
 }

public function imprintAction()
 {
     return new ViewModel();
 }
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class ClubController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function historyAction()
{
    return new ViewModel();
 }

public function managementAction()
 {
    return new ViewModel();
 }

 public function refereeAction()
 {
    return new ViewModel();
 }

public function restaurantAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class CurrentController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function newsAction()
{
    return new ViewModel();
}

public function scheduleAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function clubAction()
{
    return new ViewModel();
}

public function contactAction()
{
    return new ViewModel();
}

public function currentAction()
{
    return new ViewModel();
}

public function teamAction()
{
    return new ViewModel();
}

public function sponsorAction()
{
    return new ViewModel();
}

public function approachAction()
{
    return new ViewModel();
}

public function imprintAction()
{
    return new ViewModel();
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class SponsorController extends AbstractActionController
{
public function indexAction()
{
    //DatenbankAdapter holen
    $db = $this->getServiceLocator()->get('db');

    return new ViewModel(array('db' => $db));
}
namespace Football\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class TeamController extends AbstractActionController
{
public function indexAction()
{
    return new ViewModel();
}

public function firstAction()
{
    return new ViewModel();
}

public function tableAction()
{
    return new ViewModel();
}

public function squadAction()
{
    return new ViewModel();
}

public function secondAction()
{
    return new ViewModel();
}

public function oldAction()
{
    return new ViewModel();
}

public function djuniorAction()
{
    return new ViewModel();
}

public function efjuniorAction()
{
    return new ViewModel();
}

public function nationalAction()
{
    return new ViewModel();
}

public function utilityAction()
{
    return new ViewModel();
}

我认为你的主要问题至少可以通过两种方式解决:

  • 小队
    动作的子路由
  • 或者添加第三个可选参数,用于保存
    表|团队
    值,将其路由到团队类型的操作,并在其中添加条件。见下面的例子
配置:

// ...
'router' => array(
    'routes' => array(
        'home' => array(
            'type' => 'Literal',
            'may_terminate' => true,
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Football\Controller\Index',
                    'action'     => 'index',
                ),
            ),
        ),
        'football' => array(
            'type'    => 'segment',
            'may_terminate' => true,
            'options' => array(
                'route'    => '/:controller[/:action[/:extra]]',
                'constraints' => array(
                    'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'extra' => '(squad|table)',
                ),
                'defaults' => array(
                    'controller' => 'Football\Controller\Index',
                    'action'     => 'index',
                ),
            ),
        ),
    ),
),
至于导航:

// ...
'pages' => array(
    'first' => array(
        'type'       => 'mvc',
        'order'      => '100',
        'label'      => '1. Herren',
        'route'      => 'football',
        'controller' => 'team',
        'action'     => 'first',
        'pages' => array(
            'table' => array(
                'type'       => 'mvc',
                'order'      => '100',
                'label'      => 'Tabelle',
                'route'      => 'football',
                'params' => array(
                    'extra' => 'table',
                ),
                'controller' => 'team',
                'action'     => 'table',
            ),
            'squad' => array(
                'type'       => 'mvc',
                'order'      => '200',
                'label'      => 'Mannschaftskader',
                'route'      => 'football',
                'params' => array(
                    'extra' => 'squad',
                ),
                'controller' => 'team',
                'action'     => 'squad',
            ),
        ),
    ),

没有人对我的问题有任何想法/建议/解决方案?我很难理解你的意图。您是否可以提供一个包含操作的控制器列表,以及它们应该如何与您提供的导航结构相对应?这里的路由非常通用,很难判断应该映射到哪里。我添加了完整的module.config.php文件和我的控制器,希望这是您需要的。也许我应该再告诉你一次这个问题:我正在尝试访问这个链接,例如home->team->second->table,但是当我导航到该站点时,我将返回home->team->first->table。所以我从错误的团队那里得到了错误的桌子。我认为问题在于“子团队”路线,但我不知道如何解决它。好吧,这样更好。但是
部分应该如何工作呢?在
TeamController
中只有一个,但在导航中有多个。那么,
/team/first/table/
/team/second/table
是否应该分派到同一个动作,并且在那里您会以某种方式区分它们?是的,我认为这些链接将全部转到一个动作,并显示单击的团队的表格,如果其他,则对团队来说是相同的。我是否应该尝试另一种方法来实现这一点,或者您对此有何看法?我的另一个问题是如何解决这个/team/first/table/和/team/second/table。谢谢你的回答,但它似乎不起作用。当我想进入
/team/first/table
时,我登陆
/team/table/table
。我认为我的路由基本上有问题:/I我有一个页面add.php,这个页面在add/edit中使用相同的操作,然后如何为这个页面动态设置路由。