You are using the named parameters "id" and "fileType" in your route, but
your regex requirements are using "applicationID" and "file". The name that
comes immediately after the colon is the parameters name, so your route
should look more like this:
$applicationRoute = new
Zend_Controller_Router_Route(
'applicationID/:id/file/:fileType',
array('controller' => 'application',
'action' => array('view')),
array('id' => '\d+',
'fileType'=> '\w+')
);
router->addRoute('application', $applicationRoute);
If you do that, you won't be using the "name/value" syntax that the default
route uses. So you really don't need the "applicationID" and "file" parts of
the route. You can get away with just this:
$applicationRoute = new
Zend_Controller_Router_Route(
':id/:fileType',
array('controller' => 'application',
'action' => array('view')),
array('id' => '\d+',
'fileType'=> '\w+')
);
router->addRoute('application', $applicationRoute);
That route would match URLs like "1/foo" and "234/bar" but not "users/login"
or "page/edit".
In your controller, you can access the parameters using their names in the
route (id, fileType).
--
Hector
On Mon, Mar 22, 2010 at 1:11 PM, tonystamp <[email protected]> wrote:
>
> Hi all
>
> I have the following route defined in my bootstrap:
>
> $applicationRoute = new
> Zend_Controller_Router_Route('applicationID/:id/file/:fileType',
>
> array('controller' => 'application',
>
> 'action' => array('view')),
>
> array('applicationID' => '\d+',
>
> 'file'=> '\w+')
> );
> router->addRoute('application', $applicationRoute);
>
>
> ...and in my view script am attempting to create the url for the route as
> follows:
>
> "<?php echo $this- url(array('controller' => 'application', 'action' =>
> 'view', 'applicationID' => $application->getId(), 'file' => 'cv'),
> 'application', true); ?>">View Application
>
> ...which throws an exception, with the message "id is not specified".
> If i change the second parameter from the named route ('application') to
> 'default' the page loads fine, except i don't think the parameters are
> being
> checked against the route.
>
> What is causing the exception to be thrown?
>
>
> ps. the behaviour of the third parameter is a bit strange - why should you
> need to manually set each link to not inherit the previous routes
> parameters?
>
> --
> View this message in context:
> http://n4.nabble.com/Using-url-view-helper-with-named-custom-route-exception-id-not-specified-tp1678215p1678215.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>