controller/action vs /controller/action
Any URL created in module context is relative to the module unless fully qualified – Yii assumes the controller/action belongs to the module (most often not true).
E.g. Url::to([‘user/home’]) called in payroll\views\summary\index.php will generate host/payroll/user/home (invalid). Correct: Url::to([‘/user/home’]) (leading / ).
URLs (action routes) created and rendered in layout views (e.g. layouts/main, app-menu etc) and in module context should be fully qualified (with leading slash) otherwise they fail in module context.
Lots of cool stuff about URLs: http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html
Categories: HINTS (tehnice), Tutoriale / Reguli / Best practices |
Leave a Reply
[TOP]