开发者

Zend_Controller_Router Static Route

开发者 https://www.devze.com 2022-12-22 17:19 出处:网络
Here is my route definition in the bootstrap file: $router = $this->frontController->getRouter();

Here is my route definition in the bootstrap file:

    $router = $this->frontController->getRouter();
    $route = new Zend_Controller_Router_Route_Static(
        'tipovanie',
        array('module' => 'default',
              'cont开发者_运维技巧roller' => 'index',
              'action' => 'contest')
    );
    $router->addRoute('contest', $route);

Now when I go to /tipovanie I get correctly displayed the same content as at /index/contest.

However, I am using url view helper to construct some links in my layout like this:

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

And those links are pointing to:

/tipovanie

When viewing the /tipovanie page. On other pages without static rewritten route the url view helper works fine and the printed link is correct (for example /view/user/id/5).


I am an idiot. I forgot to specify the default route for those links:

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号