laravel-menus
laravel-menus copied to clipboard
Bootstrap 4
Hi, https://blackrockdigital.github.io/startbootstrap-modern-business/ As you can see in the Bootstrap 4 menu, the first lavel of link has the class "nav-link". For example
<a class="nav-link" href="about.html">About</a>
In the second level the class is different, For example.
<a class="dropdown-item" href="portfolio-3-col.html">3 Column Portfolio</a>
As I see in the presenter there is only one place to set de class
public function getMenuWithoutDropdownWrapper($item)
{
return '<li class="nav-item" ' . $this->getActiveState($item) . '><a class="nav-link" href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>' . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL;
}
How can we set the correct class in function of depth?
Thanks and best regards
you can create a new presenter class for bootstrap 4.
Yes, I do it but I don't know how to process the second level. I created a presenter like this one but I don't know if it's the best solution `
' . PHP_EOL; } public function getCloseTagWrapper() { return PHP_EOL . '' . PHP_EOL; } public function getMenuWithoutDropdownWrapper($item) { return '
Plus format your post, this is unreadable :D
Sorry,
Basically I created a presenter based on NavbarPresenter and override the method getChildMenuItems.
The part modified is
if ($child->hasSubMenu()) {
$results .= $this->getMultiLevelDropdownWrapper($child);
} elseif ($child->isHeader()) {
$results .= $this->getHeaderWrapper($child);
} elseif ($child->isDivider()) {
$results .= $this->getDividerWrapper();
} else {
$results .= $this->getSubmenuWithoutDropdownWrapper($child);
}
I introduce the method getSubmenuWithoutDropdownWrapper with this code
public function getSubmenuWithoutDropdownWrapper($item)
{
return '<li class="nav-item" ' . $this->getActiveState($item) . '><a class="dropdown-item" href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>' . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL;
}
This method write the correct class (dropdown-item) in the submenu.
What do you think about this aproach?
Thanks
+1 for BS4 support out of the box. Would be great. Will see if I can submit a PR.
Is there any solution at this point?
i cant make a present with bootstrap 4 :(
I did it. I used the idea of @drjoju . My implementation it was with AdminLTE 3 in SidebarMenuPresenter