【问题标题】:Zend_Controller_Router Static RouteZend_Controller_Router 静态路由
【发布时间】:2010-03-07 20:21:10
【问题描述】:

这是我在引导文件中的路由定义:

    $router = $this->frontController->getRouter();
    $route = new Zend_Controller_Router_Route_Static(
        'tipovanie',
        array('module' => 'default',
              'controller' => 'index',
              'action' => 'contest')
    );
    $router->addRoute('contest', $route);

现在,当我转到 /tipovanie 时,我会正确显示与 /index/contest 相同的内容。

但是,我正在使用 url 视图助手在我的布局中构造一些链接,如下所示:

<a href="<?php

echo $this->url(array('module' => 'default',
                      'controller' => 'view',
                      'action' => 'user',
                      'id' => $this->escape($u->id)),
                null,
                true);

                ?>"><?php echo $this->escape($u->username); ?></a>

这些链接指向:

/tipovanie

查看 /tipovanie 页面时。在其他没有静态重写路由的页面上,url 视图助手工作正常,打印的链接是正确的(例如 /view/user/id/5)。

【问题讨论】:

    标签: php zend-framework


    【解决方案1】:

    我是个白痴。我忘了为这些链接指定默认路由:

    <a href="<?php
    
    echo $this->url(array('module' => 'default',
                          'controller' => 'view',
                          'action' => 'user',
                          'id' => $this->escape($u->id)),
                    'default',
                    true);
    
                    ?>"><?php echo $this->escape($u->username); ?></a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 2022-01-04
      • 1970-01-01
      • 2015-06-01
      • 2017-07-27
      • 2013-07-27
      • 2018-11-26
      相关资源
      最近更新 更多