Zend_Controller_Router静态路由

时间:2010-03-07 20:21:10

标签: php zend-framework

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

    $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 view helper在我的布局中构建一些链接,如下所示:

<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)。

1 个答案:

答案 0 :(得分:0)

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

<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>
相关问题