I made a custom router for this purpose(see attachment). It's identical to Zend_Controller_Router_Route_Module with slightly modified match() and assemble() methods.
The default Module router basically explodes the path, walks through it,
takes each part then assigns them to the module (only if the first part is a
valid module, otherwise it is set to default), controller and action
respectively then the rest is set as params. I modified it to also check if
the controller is valid by making a test request and calling
$dispatcher->isDispatchable() on it. I don't know if that's the proper way
to do it, but it works good enough for my needs.
For the action part, since actions are called via a magic function (I think)
there's no way to test if an action is defined without catching exceptions.
So I just made an assumption that the requested action is the default action
if the remaining parts (after assigning the module and controller) has an
even number of elements. Otherwise, the next part is used as the action and
the rest as param=>value pairs. So this router won't work as expected if you
have a param with no matching value.
On Tue, Oct 21, 2008 at 7:54 AM, t-mow <[EMAIL PROTECTED]> wrote:
>
> Hi guys,
>
> my solution for this is adding this route in bootstrap:
> $front->getRouter()->addRoute('indexFix', new
> Zend_Controller_Router_Route(':action',
> array('module'=>'default','controller'=>'index','action'=>'')));
>
> The only point thats not that cool, is that you cannot call any other
> controller just by it's controller name - you'll have to specify an action
> to access these. For example /users/search will work, just "/users" won't,
> because it will call IndexController::usersAction ;)
>
>
> David Mintz-3 wrote:
> >
> > On Sun, Oct 19, 2008 at 9:31 AM, till <[EMAIL PROTECTED]> wrote:
> >
> >> On Sun, Oct 19, 2008 at 7:25 AM, TimTowdi <[EMAIL PROTECTED]> wrote:
> >> >
> >> > I want all actions for my IndexController to work using only the
> action
> >> name,
> >> > and actually redirecting if the index controller name is used. So:
> >> > http://example.com/index/sitemap/
> >> > Would actually issue a redirect to:
> >> > http://example.com/sitemap/
> >> >
> >> >
> >> > However, I will have other controllers, and I want them to use both
> >> > controller and action, so for the indexAction of AdminController:
> >> > http://example.com/admin/
> >> > And for the loginAction of AdminController:
> >> > http://example.com/admin/login/
> >> >
> >> > How would this best be accomplished?
> >>
> >> Don't hold me responsible for typos, but ...
> >>
> >> $router->addRoute('sitemap',
> >> new Zend_Controller_Router_Route('/sitemap',
> >> array('controller' => 'index', 'action' => 'sitemap', 'module' =>
> >> 'default')));
> >>
> >> That should go in your bootstrap, whereever you setup your routes.
> >
> >
> >
> > I think he wants to know one routing recipe whereby all the actions in
> his
> > index controller can be accessed as example.org/action instead of
> > example.org/index/action. I have wondered the same thing but was afraid
> to
> > ask :-) Though I could image an intelligent 404 handler but that doesn't
> > seem the most efficient solution.
> >
> >
> >
> > --
> > David Mintz
> > http://davidmintz.org/
> >
> > The subtle source is clear and bright
> > The tributary streams flow through the darkness
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Routing-so-that-%27index%27-never-shows-up-in-the-url--tp20053411p20081102.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>
Default.php
Description: Binary data
