Question

I have a problem with custom zend router. this is my cat router

$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$router->addRoute('categories', new Zend_Controller_Router_Route(
        'video/k/:id/:title',array(
            'controller' => 'video',
            'module' => 'default' ,
            'action' => 'k',
            'id' => '',
            'title' =>''
            )
    ));

$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();

when i try htttp://dev.dummy.com/video/k/1/foo works fine but

$this->url(array_merge($params, array('order' => 'title'))) or
$this->url(array_merge($params, array('order' => 'title')),'categories')
$this->url(array_merge($params, array('order' => 'title')),'categories', true)

doesnt return htttp://dev.dummy.com/video/k/1/foo/order/title still returning htttp://dev.dummy.com/video/k/1/foo.

Hope this help. Thanks.

No correct solution

OTHER TIPS

Try setting the third parameter $reset of the url-helper to true:

$this->url(array_merge($params, array('order' => 'title')), 'categories', true)

This will reset the default parameters.

(Documentation at http://framework.zend.com/manual/1.12/en/zend.view.helpers.html#zend.view.helpers.initial)

When doing the array_merge, the integer keys will be reset to start from beginning. Just append your array instead of the array_merge:

    $router->addRoute('categories', new Zend_Controller_Router_Route(
    'index/test/:id/:title',array(
        'controller' => 'index',
        'module' => 'default' ,
        'action' => 'test',
        'id' => '',
        'title' => ''

        )
     ));

   echo $this->url(array('order' => 'title')); 

Tried it with http://dev.dummy.com/video/k/1/foo and http://dev.dummy.chom/video/k/1/foo/order/title/. In both cases, the url helper output was - htttp://dev.dummy.com/video/k/1/foo/order/title

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top