tags:

views:

37

answers:

1

I am currently outputting the url of a particular module like so:

$this->view->url(array('controller'=>'index','action'=>'index','module'=>'somemodule'))

The problem is when I view:

/somemodule/action1/paramid/paramval

The url is showing as:

/somemodule/index/index/paramid/paramval

When all I really want is:

/somemodule/

Any ideas? I have used the above url array because I am trying to force it to display the correct url. sadly, simply array('module'=>'somemodule') doesn't work...

A: 

Weird, I would've thought it defaults to index/index if they aren't specified. You could try setting up something with Zend_Controller_Router_Route;

$router = $ctrl->getRouter(); // returns a rewrite router by default
$router->addRoute(
    'user',
    new Zend_Controller_Router_Route('somemodule',
                                     array('module' => 'somemodule',
                                           'controller' => 'index',
                                           'action' => 'index'))
);

You will however need to set up routes to capture the :id/:val into variables. You can do this with another addRoute(), naming each variable prepending a colon.

$router->addRoute(
    'user',
    new Zend_Controller_Router_Route('somemodule/:id/:val',
                                     array('module' => 'somemodule',
                                           'controller' => 'index',
                                           'action' => 'index'))
);

Then you should be able to view the module without the index/index in the URL which might fix the problem with the url helper.

More info here http://framework.zend.com/manual/en/zend.controller.router.html

pharalia