0

This is possible in Symfony with some routing magic but in Zend I'm not sure how to do this.

I want to make this url

http://example.com/unit/view/id/[15] 

look like this instead

http://example.com/unit/[15]/view/[name] 

where unit/view is the controller/action and id/15 is parameter key=>value, and [name] is the name of the unit being retrieved (in this case unit id 15).

1
  • Do you want the name to be looked up automatically (in a database or something like this) or do you add it to your route manually? Commented Oct 23, 2010 at 16:27

2 Answers 2

2

Yes, it can be done. Using the router:

In your bootstrap:

$router = $zendControllerFront->getRouter(); $router->addRoute('routeName', new Zend_Controller_Router_Route('/unit/:id/view/:name'), array('controller' => 'unit', 'action' => 'view') ); 
Sign up to request clarification or add additional context in comments.

Comments

0

You can add the route also in your application.ini:

resources.router.routes.myroute.route = ":controller/:id/:action/:name" 

Then unit maps automatically to your controller (:controller variable here) and the action (:action). More information about these paramters used in Zend_Config files at the manual: http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.add-config

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.