Strange, i don't get any error??
On 12 Dec 2009, at 16:16, umpirsky <[email protected]> wrote:
It processed the route from config as well, but throwed same error.
Error does not occurs in url helper, like your reproduced case, but
also
when I type in address bar
http://mysite.com/oglas/25
direct visiting my new route. Does it works same for you?
Regards,
Saša Stamenković.
Daniel Latter wrote:
Hi,
OK, at least its processing you route.
I manged to re-create this error by passing a null value to the id
parameter
when using the url helper, maybe this is your problem?
Try: <?php echo $this->url(array(), 'car'); ?> and see if that works.
Dan
2009/12/12 umpirsky <[email protected]>
Hi.
I get same as you from url helper. But visiting /oglas/25 gives me
Fatal error: Uncaught exception 'Zend_Controller_Router_Exception'
with
message 'id is not specified' in Zend\Controller\Router\Route.php:
350
again (zf 1.9.6). So I get same behaviour as with application.ini :(
Thanks for help again.
Daniel Latter wrote:
Sorry, there is a typo in my email I have used 'olgas' instead of
'oglas'
2009/12/12 Daniel Latter <[email protected]>
Hi umpirsky,
I have done some testing and I cant get the config method to
work but
the
following works for fine me:
// bootstrap _init function
// http://forums.zend.com/viewtopic.php?f=69&t=1312#p4770
public function _initRouter()
{
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$routes = array(
'car' => new Zend_Controller_Router_Route(
'olgas/:id',
array('controller' => 'car',
'action'
=>
'view')
)
);
// Add some routes
$router->addRoutes($routes);
//...
// Returns the router resource to bootstrap resource registry
return $router;
}
// helper
<?php echo $this->url(array('id' => 22), 'car'); ?> = /olgas/22
Also its defiantly possible to have something like:
/oglas/product-name/25 -> Look into Route_Regex.
HTH
Dan
2009/12/12 umpirsky <[email protected]>
I tried that as well, but got
Zend_Controller_Dispatcher_Exception: Invalid controller
specified
(oglas)
thrown in Zend\Controller\Dispatcher\Standard.php on line 242
as I said above.
What url helper generates (oglas/25) is even better, but get
fatal
error
(also explained above).
Thanks for the answer anyway ;)
Daniel Latter wrote:
Judging by what u want, shouldn't it be: /oglas/id/:id ?
On 12 Dec 2009, at 10:52, umpirsky <[email protected]> wrote:
Hi.
I want my url /default/car/view/id/25 to turn into /oglas/id/25
In order to achieve this, I added in application.ini
resources.router.routes.car.route = "/oglas/:id"
resources.router.routes.car.defaults.module = "default"
resources.router.routes.car.defaults.controller = "car"
resources.router.routes.car.defaults.action = "view"
When I try to visit /oglas/id/25, I get
Zend_Controller_Dispatcher_Exception: Invalid controller
specified
(oglas)
thrown in Zend\Controller\Dispatcher\Standard.php on line 242
When I use view helper to generate url
" href="<?= $this->url(array('id' => $car->id), 'car') ?>">
It generates /oglas/25 which gives
Uncaught exception 'Zend_Controller_Router_Exception' with
message
'id is
not specified' in Zend\Controller\Router\Route.php:350
Where did I go wrong?
And later, it would be even nicer if I can add some string
after
oglas, like
/oglas/product-name/25
for better SEO. Is that possible?
Regards,
Saša Stamenković.
--
View this message in context:
http://n4.nabble.com/Adding-simple-route-in-application-ini-tp961683p961683.html
Sent from the Zend Framework mailing list archive at
Nabble.com.
--
View this message in context:
http://n4.nabble.com/Adding-simple-route-in-application-ini-tp961683p961693.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
View this message in context:
http://n4.nabble.com/Adding-simple-route-in-application-ini-tp961683p961779.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
View this message in context:
http://n4.nabble.com/Adding-simple-route-in-application-ini-tp961683p961815.html
Sent from the Zend Framework mailing list archive at Nabble.com.