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
812 stars 207 forks source link

Update app-menu.md #2105

Closed hbugdoll closed 3 years ago

hbugdoll commented 3 years ago

minor improvements

hbugdoll commented 3 years ago

One shouldn't use Yii::$app->menu->current inside blocks, right? It obviously points to the homepage, but not to the current page.

nadar commented 3 years ago

Current should always Point to the current menu item, while homepage points to the homepage. If current always points to the same page, i think its due to caching of the block itself

nadar commented 3 years ago

Thanks for the text update @hbugdoll once again!

hbugdoll commented 2 years ago

Current should always Point to the current menu item, while homepage points to the homepage. If current always points to the same page, i think its due to caching of the block itself

I was not precisely enough in usage of current. And after some research it becomes clearer:

Yii::$app->menu->current points to the current menu item in frontend, but not inside backend's admin(). In this case Menu::resolveCurrent() calls Menu::getHome(): https://github.com/luyadev/luya-module-cms/blob/a2697808f1ac261dbad79594138b5807e8ec942d/src/Menu.php#L522-L532