2011年1月7日星期五

[fw-mvc] Routing

Hello all

I am trying to route from http://localhost/index/show/articleID/1 to
http://localhost/show/articleID/1.

application/Controllers/IndexController

public function indexAction()
{
$articles = new Application_Model_Articles();
$this->view->articles = $articles->listArticles();
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->addRoute('show',
new Zend_Controller_Router_Route('show/*', array(
'controller' => 'index',
'action' => 'show'
))
);

I call this in view as follow
index.phtml
<a href="<?php echo $this->url(array('articleID' => $articles->articleID),
'show') ?>">Show</a>

But everytime it tries to route me to ShowController which does not exist.
As I understand it suppose to route to showaction. Is there anything I am
missing?

Best Regards

没有评论: