-
Notifications
You must be signed in to change notification settings - Fork 201
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
Tutorial/Dropdown for Symfony 4.2, bootstrap(s), etc, navbar, dropdown, etc. #397
Comments
Having struggled with this issue for a couple of days now I've come to the conclusion that "you can't get there from here." What convinced me of this was attempting to reproduce this:
with this:
The problem was that none of the link attributes are assigned to the dropdown toggle So more basic html coding ahead. |
Bonjour je sais pas si vous avez trouver une solution a votre problème mais moi aussi je suis dans le même problème si vous pouvez me faire part de votre solution. |
Problème identique. Pas de pistes de solutions ? |
In my base menu class, I've added a utility (um, hack?), and now all my nav menu methods return the cleaned menu.
public function cleanupMenu(ItemInterface $menu): ItemInterface
{
$menu->setChildrenAttribute('class', 'navbar-nav');
// menu items
foreach ($menu as $child) {
$child->setLinkAttribute('class', 'nav-link')
->setAttribute('class', 'nav-item');
}
return $menu;
} |
I'm having a really hard time creating a simple bootstrap navbar with a dropdown.
There are LOTS of webpages that describe how to do it, but I haven't had any luck with any solution, except to use MopaBootstrapBundle, which seems like overkill for just a navbar.
In the same way that Symfony forms has a few built-in options (bootstrap_3_horizontal, etc.), I basically want to simply set the twig theme and then configure the top navbar, side navbar, etc.
Part of the confusion is how many options there are. Many of them examples on the web add the class and attributes in the menu creation, but that seems like a very bad practice, to lock in that a menu item is of the navbar-item class. That'd make more sense when rendering the menu (from the twig template).
Regardless, despite hours of hacking I'm unable to get a simple bootstrap navbar or sidebar menu working. Can anyone point me to a working example of a navbar with dropdown that includes a MenuBuilder class, the html/twig that renders it?
The text was updated successfully, but these errors were encountered: