My main router goes like this (simplified):
'router' => [
'routes' => [
'blog' => [
'type' => 'regex',
'options' => [
'regex' => "/(?<language>[a-z]{2})?",
'spec' => "/%language%",
'defaults' => [
'controller' => 'Blog\Controller\Posts',
'action' => 'index'
],
],
'may_terminate' => true,
'child_routes' => [
// [...]
'add_post' => [
'type' => 'literal',
'options' => [
'route' => '/admin/post/add',
'defaults' => [
'controller' => 'Blog\Controller\Posts',
'action' => 'add'
]
]
], // end add post
] // end child routes
] // end blog route (main route)
] // end routes
] // end Router
And in the template displayed on "/en/admin/post/add" I have a call to $this->url()
, that ends up printing /%language%/admin/post/add
.
I have the language code available on $language
on my template, and
I'd like to pass it on to url()
so it properly constructs the the url using the spec.
Also, I'd like, if possible, not to specify the name of the route on my call to url()
, so it uses the default one for $this
.
How would I go around to accomplish this?
Thanks and regards