Wrong url in layout context
What steps will reproduce the problem?
Using Url::toRoute(['/crawler/default/index']) inside the layout file will generate "domain.com/crawler/default/index" correctly on start/root page.
But on subpages like "domain.com/contact" wrong url will be generated "domain.com/contact/default/index"
What is the expected result?
Url::toRoute(['/crawler/default/index']) should generated the same URL on subpages too.
and crawler is the module name in the config i assume?
Yes it is.
When using CMS, you should use https://luya.io/api/luya-cms-helpers-Url to link to the page which includes the module. But maybe we can fix it somehow. Need to make unit tests for this case
I think the problem ist here -> https://github.com/luyadev/luya/blob/4e5a9db3a869f289c2af15406252dd0a4078e95b/core/web/UrlManager.php#L381
$isOutgoingModulePage is false because the current navitem is the cms page and not a Module Page -> https://github.com/luyadev/luya/blob/4e5a9db3a869f289c2af15406252dd0a4078e95b/core/web/UrlManager.php#L368
Maybe the UrlHelper need a option or function to generate url with out navitem context.
Try this: https://github.com/luyadev/luya/blob/master/core/helpers/Url.php#L47-L54
maybe this needs better documentation
Does that fixed the issue?
That it's, thank you!
I got the same problem in cms module context with the captcha image url. In \yii\captcha\Captcha::run the Html::img will called which use the Url::to function.
The captcha widget is used in a module context block under /contact. The generated url for the image is /contact/captcha and not /site/captcha
Yes its true, in this case you might define an url rule, so LUYA knows the route and prefix the the current cms page correctly.
I am going to close this issue because:
- Its a question (Please post questions at LUYA discussions)
- Missing information's
- No more activity
- No one picked up the task (no Pull Request received)
If you think this is still important or there are more/new informations. Please reopen the issue and let us know.
If this is a problem or a feature you like to discuss, join our discussion: LUYA discussions. We try to keep our issue tracker as clean as possible in order to focus on active issues.