I’m trying to create a second Log1x/Navi menu inside of sage 10. I’ve seen a couple similar posts addressing this issue but I’m still getting an empty menu.
Similar posts:
Here is my setup.php
register_nav_menus([
'primary_navigation' => __('Primary Navigation', 'sage'),
'top_navigation' => __('Top Navigation', 'sage'),
]);
My Navigation.php
<?php
namespace App\View\Composers;
use Roots\Acorn\View\Composer;
use Log1x\Navi\Facades\Navi;
class Navigation extends Composer
{
protected static $views = [
'partials.navigation',
'partials.top-navigation',
];
public function with()
{
return [
'primary' => $this->primary(),
'topnav' => $this->topnav(),
];
}
public function primary()
{
if (Navi::build('primary')->isEmpty()) {
return;
}
return Navi::build('primary')->toArray();
}
public function topnav()
{
if (Navi::build('topnav')->isEmpty()) {
return;
}
return Navi::build('topnav')->toArray();
}
}
Here is my top-navigation.blade.php as an example:
@if ($topnav)
@foreach ($topnav as $item)
@if (! $item->children)
<li class="nav-item {{ $item->classes ?? '' }} {{ $item->active ? 'active' : '' }}">
<a class="nav-link text-light small px-3" href="{{ $item->url }}">
{{ $item->label }}
</a>
</li>
@endif
@endforeach
@endif
Finally here is my header.blade.php
<header class="banner fixed-top pt-5 ps-5">
<div class="navbar p-0 navbar-light" aria-label="{{ wp_get_nav_menu_name('primary_navigation') }}">
<div class="container-fluid p-0">
<button class="align-self-start navbar-toggler border-0 p-4" type="button" data-bs-toggle="modal" data-bs-target="#navigation-modal" aria-controls="navigation-modal" aria-expanded="false" aria-label="Toggle navigation modal">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand p-4 m-0" href="/" name="Davis Logo">
filler
</a>
<ul id="navbars-header" class="navbar-nav collapse navbar-collapse justify-content-end">
@include('partials.navigation', ['menu' => 'primary_navigation', 'children' => 'true' ])
</ul>
</div>
</div>
<ul class="list-unstyled position-absolute top-0 end-0 d-flex justify-content-center align-items-center">
@include('partials.top-navigation', ['menu' => 'top_navigation', 'children' => 'true' ])
</ul>
</header>
The primary nav is showing up on the front-end. I am getting no errors in wordpress and if I inspect the top-navigation menu it just shows an empty ul
Note: I have already made sure that the checkbox’s in the wordpress backend are selected for each of the two menu locations. This is my first post on discourse so please let me know if this should be posted under a new category or a different place.
Thanks in advance!