2011年1月7日星期五

Re: [fw-mvc] Routing

Hello Erdal, I think that your code have a little mistake, I use Zend_Route
and I changing the code in red:

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/:articleId', array(
'controller' => 'index',
'action' => 'show'
))
);

:articleId --> This a varible that you receive whit
_getParameter("articleId") and containt the value of the id.

I hope that this line help you.
Best Regards Juan Pablo.


2011/1/7 Erdal YAZICIOGLU <erdal.yazicioglu@gmail.com>

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

没有评论: