Monday, March 20, 2017

Getting 2 different li tags in laravel

I'm trying to create a menu in laravel 5.4. The problem I'm having is because of my code if my menu item has a seo attached to it then my link is inside the li tag, but because of this if my menu item doesn't have a seo attched to it I just have a link that isn't inside an li tag. I'm not sure how to go about doing it so that I can get the link inside the li tag regardless of if there is a seo or not.

As it stands in my firebug this is how my menu looks

<nav class="navbar navbar-default">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main_menu" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>

      <div class="collapse navbar-collapse menubar" id="main_menu">
        <ul class="nav navbar-nav" id="menu">
          <li class="parent ">
            <a href="http://localhost/writers-circle/public/home.html">home</a>
          </li>
          <a href="http://localhost/writers-circle/public/3">stories</a> <!-- HERE IS WHERE THE PROBLEM IS -->
        </ul>
      </div>
    </div>
</nav>

menu.blade.php

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main_menu" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>

    <div class="collapse navbar-collapse menubar" id="main_menu">
      <ul class="nav navbar-nav" id="menu">
        @foreach($menus_child as $grandfather)
          @foreach($grandfather->seo as $seo)
            <li class="parent {!! (current_page($seo->url)) ? 'current' : '' !!}">
          @endforeach
            {!! Html::link(getSeoLink($grandfather->id), $grandfather->title) !!}
            </li>
        @endforeach
      </ul>
    </div>
  </div>
</nav>

I hope I made sense in my question.



via Isis

Advertisement