luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
811 stars 205 forks source link

Unique url in Modul-Block context #1855

Closed boehsermoe closed 5 years ago

boehsermoe commented 6 years ago

What steps will reproduce the problem?

Create new page with the name mypage add a module block to the content and select a module (e.g. mymodule). Inside the action/view create a url with \luya\helpers\Url::toRoute(['/mymodule/other-controller/index', 'id' => 1])

What is the expected result?

Generated url should be https://example.com/mymodule/other-controller/index/id/1

What do you get instead? (A Screenshot can help us a lot!)

But I get https://example.com/mypage/other-controller/index/id/1

It is important for SEO to have unique urls. Maybe resolve this with a config option in the module block?

nadar commented 6 years ago

sorry for the late reply @boehsermoe

So you would like to have the url you have defined in the config like mymodule - this url still works, so maybe you should not implement the module as part of the cms (module page or module block), maybe just redirect from the navigation to the module /mymodule - currently i don't think this is what people expect: placing a module but url points to another page - which not even exsits in the menu tree.

what do you think?

boehsermoe commented 5 years ago

I dont mean the target url to the page. The problem is that I have a link inside the module block. The url for the page A is https://example.com/mypageA and it contains a module block (mymoduleA). And in the view of the module block I create an anchor like Html::a("link", ['/mymoduleB/other-controller/index', 'id' => 1]) and the result is currently https://example.com/mypageA/other-controller/index/id/1 but should be https://example.com/mymoduleB/other-controller/index/id/1.

nadar commented 5 years ago

What does the url for this linke looks like? does https://luya.io/api/luya-cms-helpers-Url toModuleRoute works?

boehsermoe commented 5 years ago

toModuleRoute doesnt help because the mymoduleB is not in the menu.

Html::a("link", ['/mymoduleB/other-controller/index'])

Result https://example.com/mypageA/other-controller/index

Expect https://example.com/mymoduleB/other-controller/index

In the UrlManager::urlReplaceModule every module route which exists in the app will be replaced with current context route. But it should only replace the module route if it is the same module class, right?

nadar commented 5 years ago

Okay i see, yes i agree on this:

But it should only replace the module route if it is the same module class