caffeinated / menus

:pushpin: Menu generator package for the Laravel framework
https://caffeinatedpackages.com
132 stars 59 forks source link

Active Menu Link Improvements #44

Closed kaidesu closed 9 years ago

kaidesu commented 9 years ago

There have been numerous issues created around the automatic active-state detection (#25, #32, #42, and #43). This issue will replace all the other open issues to keep things consolidated in one location.

The active-state detection does not take into consideration dynamic URI segments that may be attributed to the menu item. Below we'll look at an example.

We have a menu defined as follows:

Menu::make('example', function($menu) {
    $menu->add('Blog', '#');
    $menu->blog->add('Manage Posts', 'admin/blog');
    $menu->blog->add('Write New Post', 'admin/blog/create');
});

The following URI's trigger the active state as defined:

URI Triggers Should Trigger
admin/blog Blog and Manage Posts Blog and Manage Posts
admin/blog/create Blog and Write New Post Blog and Write New Post
admin/blog/edit/1 N/A Blog
kaidesu commented 9 years ago

https://github.com/caffeinated/menus/wiki/Active-Link-Detection#wildcard-detection