I am trying to utilize the Tag::linkTo
functionality in my views to generate links. However, I do not want to explicitly type a link (such as /my-url
).
For example, I have a controller called GameController
. Default routes are enabled, so this is accessible via /game/
and /game/index
, as you would expect. I have created a custom route allowing this to also be accessible via /overview
.
I want to pass the controller and the action I wish to link to, and then generate a link to whatever route was matched. In this scenario, I would pass it controller => game, action => index
and it would return /overview
- falling back to default routing (like /game/
or /game/index
) if no route was defined for that pair. This would allow my websites links to update automatically if the route to a particular controller/action changes.
Is there some way to do this? In CakePHP, the HTML helper can accept controller/action arguments and return a link to the appropriate route. I am not seeing similar functionality in any of the linkTo
examples on the documentation page.