I believe what you're looking for is $html->url() or, more direct,
Router::url().
http://api.cakephp.org/class_router.html#a34cdc409ebe46302682fb8c242c4838
Also, you should lookup URLs with an array like
array('controller' => 'groups', 'action' => 'something')
instead of /groups/something. Seems more reliable for reverse lookups
in my experience.
On 9 Oct 2008, at 17:23, Andreas Hofmann wrote:
>
> Hi all,
>
> i discovered the whole Router-class-definition, but I found no method,
> that matches my needs :)
> Is there any way to get the URL of a defined route for an internal
> cake-controller/action-URL.
>
> For example I have this route defined:
>
> Router::connect('/gruppen', array('controller' => 'groups', 'action'
> => 'index'));
>
> Is there now a way to get this defined URL ('/gruppen') by calling a
> function with the params controller/action, like this:
>
> Router::theMagicMethodThatMustExist(
> array(
> 'controller' => 'groups'
> 'action' => 'index'
> )
> ); // Should now return '/gruppen'
>
> With this I can undock the URLs from the templates/views! Currently
> I'm doing stuff like this in a view:
>
> $html->link('A Link', '/groups/index');
>
> But this sucks, because when I define a route for '/groups/index', I
> don't want to change the URL in 1000 view-files and replace '/groups/
> index' with '/gruppen' :S Would be nice if there is a method I'm
> looking for, to always get a defined route-URL, if there is one! :)
>
> Is there such a method out there??
>
> Thanks and greetings,
>
> Andreas!
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---