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.
>

Reply via email to