-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
current or active route.. #2
Comments
I'm actually working on this feature and will push it up today. Thanks for the comment :) |
That will be great =) just fell in love with you 😝 |
haha. I'm glad you like the package :) |
Yeah, that would be nice. =) |
I accomplished this by wrapping my menu in a Route filter, e.g.: Menu::make('myMenu', function($menu) {
Route::filter('myFilter', function($route, $request) use ($menu) {
// $route is the current route
$someParameter = $route->getParameter('someParameter');
$menu->add('Link', ['route' => ['someRouteName', 'someParameter' => $someParameter]]);
});
}); |
My solution if maybe somebody else is interested: $createMenu = function($guestMenu) {
$guestMenu->add(trans('menu.dashboard'), array('route' => 'dashboard'));
$guestMenu->add('Produkte', array('route' => 'dashboard'));
};
$guestMenu = Menu::make('mainNav', $createMenu);
// here is the filter to find the active item
$guestMenu->filter(function($item) {
if(route($item->link->path['route']) == Request::url()) { // but then all items must have a route
$item->active();
}
return true;
}); |
I did something similar to mnewmedia:
Sometimes I'd like to mark an item as active when the user is in a sub-path so I might adjust this at some point to allow some sort of wildcard matching, but for now this works. |
@mnewmedia / @dustingraham - You guys should check out Example: Request::is('foo/*'); |
@leek Yes, I'm using Request::is in another system. It just didn't seem to fall in to place here. We may need another parameter in the menu->add function for active url match or something to that effect. |
Instead of relying on wildcard URL matching for activating parent nodes, I used You can choose which item to be activated (Item or Link) in <?php
// ...
'active_element' => 'item', // item|link
// ... |
oh what damn fantastic create news =) |
didn't search for it, but anyway a built in solution for current or active menu-item would be great...
An really this one is the best menu Builder for Laravel out there !! Thanks for making it =)
The text was updated successfully, but these errors were encountered: