But even that does not help. I changed a litle bit the code. But I still
have the invalid controller (show) message while it is an action in
IndexController
front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$route = new Zend_Controller_Router_Route(
'show/:articleID',
array(
'controller'=>'index',
'action'=>'show'));
$router->addRoute('show', $route);
2011/1/7 Juan Pablo Marroni <jmarroni@gmail.com>
> 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
>>
>
>
没有评论:
发表评论