Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy terms in breadcrumb #24

Open
vincenzolegrottaglie opened this issue Apr 16, 2024 · 0 comments
Open

Taxonomy terms in breadcrumb #24

vincenzolegrottaglie opened this issue Apr 16, 2024 · 0 comments

Comments

@vincenzolegrottaglie
Copy link

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:
Screenshot 2024-04-16 alle 12 57 00

What I expect is Home -> Custom Post Type -> Taxonomy Term (if post have one) -> Post.

How to deal with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant