0

I have a route defined as below.

$route['manage-vehicles'] = new Zend_Controller_Router_Route(
  'vehicles/manage/page/:page',
  array(
    'controller' => 'vehicles',
    'action'     => 'manage',
    'page'       => '1'
  )
);

When the 'page' parameter is not specifically defined (e.g. in a menu constructed using the navigation component), the resultant URL is

/vehicles/manage/page

I would much prefer or the URL not to to display the default paramater key in this scenario

i.e. /vehicles/manage

Any ideas how to accomplish this would be appreciated?

Thanks.

EDIT: For clarity, I would like vehicles/manage/page/1 etc to display when the 'page' parameter is defined

NaNuk
  • 141
  • 9

1 Answers1

0

The 'page' string you have in your route is not required for the page parameter to work, so all you need to do is change your route to:

$route['manage-vehicles'] = new Zend_Controller_Router_Route(
  'vehicles/manage/:page',
  array(
    'controller' => 'vehicles',
    'action'     => 'manage',
    'page'       => '1'
  )
);

you've told it which thing in the URL is 'page', so you don't need the prefix there. That's just part of the default route where the parameters are not predefined.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
  • Tim, thanks for responding. Yes I have other routes for which I do that e.g. vehicle/update/1, but in this case I think displaying the 'key' when paginating is more friendly. For the URL vehicles/manage/2, the purpose of the 2 is obscure. – NaNuk Jul 11 '12 at 15:30