Closed
Description
Module version: v3.0.3
PHP version: 8.3
I've added 2 new menu's in setup.php
:
/**
* Register the navigation menus.
*
* @link https://developer.wordpress.org/reference/functions/register_nav_menus/
*/
register_nav_menus([
'primary_navigation' => __('Primary Navigation', 'sage'),
'secondary_navigation' => __('Secondary Navigation', 'sage'),
'footer_categories_navigation' => __('Footer Categories Navigation', 'sage'),
'footer_info_navigation' => __('Footer Information Navigation', 'sage'),
]);
In my footer.php file I include the two menu's:
<div class="">
<h3 class="text-xl font-extrabold">Shopcategoriën</h3>
@if (has_nav_menu('footer_categories_navigation'))
@include('components.navigation-footer', ['name' => 'footer_categories_navigation'])
@endif
</div>
<div class="">
<h3 class="text-xl font-extrabold">Informatie</h3>
@if (has_nav_menu('footer_info_navigation'))
@include('components.navigation-footer', ['name' => 'footer_info_navigation'])
@endif
</div>
And the navigation-footer.blade.php
file currently looks like this:
@props([
'name' => null,
'inactive' => 'py-2 border-b text-primary font-light transition-colors',
'active' => 'py-2 border-b text-primary font-light transition-colors',
])
@php($menu = \Log1x\Navi\Navi::make()->build($name))
@if ($menu->isNotEmpty())
<ul {{ $attributes->merge(['class' => "flex flex-col"]) }}>
@foreach ($menu->all() as $item)
<li class="{{ $item->classes }} {{ $item->active ? $active : $inactive }}">
<a href="{{ $item->url }}">
{{ $item->label }}
</a>
@if ($item->children)
<ul>
@foreach ($item->children as $child)
<li @class([
$child->classes,
$inactive => ! $child->active,
$active => $child->active,
])>
<a href="{{ $child->url }}">
{{ $child->label }}
</a>
</li>
@endforeach
</ul>
@endif
</li>
@endforeach
</ul>
@endif
Somehow only the last element in the @class
directive is showing. Either $inactive or $active depending on which one I put last in the @class
directive.
I temporary solved the issue for my case by using a similar structure as in the vanilla template:
<li class="{{ $item->classes }} {{ $item->active ? $active : $inactive }}">
Metadata
Metadata
Assignees
Labels
No labels