artkonekt / menu

Laravel Menu Component
MIT License
26 stars 150 forks source link

Making a section item #4

Closed mertasan closed 3 years ago

mertasan commented 3 years ago

I don't want to use links in some items. How can I do that?

$menu = Menu::create('main');

$menu->addItem('home', 'Home', '/');
$menu->addItem('section', 'Section Title',  ['url' => false, 'class' => 'menu-section']); // example: [url => false]
$menu->addItem('about', 'About', '/about');
<ul>
  <li class="active"><a href="http://yourdomain.com">Home</a></li>
  <li class="menu-section">
      <h4 class="menu-text">Section Title</h4>
  </li>
  <li><a href="http://yourdomain.com/about">About</a></li>
</ul>
fulopattila122 commented 3 years ago

Just don't pass an url (or pass null) See this similar example: https://github.com/artkonekt/appshell/blob/2.0.0/src/Providers/BootsAppShellMenu.php#L40

Update:

Just don't pass the url in the array:

$menu = Menu::create('main');

$menu->addItem('home', 'Home', '/');
$menu->addItem('section', 'Section Title',  ['class' => 'menu-section']);
$menu->addItem('about', 'About', '/about');
mertasan commented 3 years ago

Thank you @fulopattila122