Taxonomy terms in breadcrumb
vincenzolegrottaglie opened this issue · 0 comments
vincenzolegrottaglie commented
Hi, I'm using this package for the first time. I successfully managed to create a bredcrumb, but I need to show also associated taxonomy term between page and post title.
app/View/Components/Breadcrumb.php
<?php
namespace App\View\Components;
use Illuminate\View\Component;
use Log1x\Crumb\Facades\Crumb;
class Breadcrumb extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}
public function items()
{
return Crumb::build()->toArray();
}
/**
* Get the view / contents that represent the component.
*/
public function render()
{
return $this->view('components.breadcrumb');
}
}
and this is my blade
resources/views/components/breadcrumb.blade.php
@if (!empty($items))
<nav class="n7-breadcrumb " aria-label="Breadcrumb">
<ol class="flex flex-wrap">
@foreach ($items as $item)
@if (empty($item['url']))
<li>
<a class="inline-flex items-center p-1 text-xs n7-content-03 font-bold hover:underline"
href="#" aria-current="page">
{!! $item['label'] !!}
</a>
</li>
@else
<li>
<a class="inline-flex items-center p-1 text-xs n7-content-03 hover:underline"
href="{{ $item['url'] }}">
@if ($loop->first)
{!! __('Home', 'offhealth') !!}
@else
{!! $item['label'] !!}
@endif
</li>
@if (!$loop->last)
<svg class="inline-block align-middle fill-current w-4 h-4 text-neutral-400 ml-2"
aria-hidden="true" focusable="false" role="img">
<use xlink:href="@asset('images/icons.svg')#mini--chevron-right" />
</svg>
@endif
</a>
@endif
@endforeach
</ol>
</nav>
@endif
The result is Home -> Custom Post Type -> Post:
What I expect is Home -> Custom Post Type -> Taxonomy Term (if post have one) -> Post.
How to deal with this?