带有链接的 Laravel 动态面包屑 [英] Laravel dynamic breadcrumbs with links

查看:22
本文介绍了带有链接的 Laravel 动态面包屑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在带有链接的 laravel 中实现动态面包屑.我通过以下代码成功渲染了面包屑但没有链接.

 

但现在我遇到了网址问题.我正在获取所有后代的路线的当前网址.有人可以帮助我如何添加指向面包屑的链接吗?

谢谢.

解决方案

如果我正确理解您的问题,您只需填写链接的 URL.这是未经测试的,但我认为它应该可以工作.

I am trying to implement dynamic breadcrumbs in laravel with links. I successfully render the breadcrumbs but without links by following code.

    <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i>Marketplace</a></li>
    @foreach(Request::segments() as $segment)
    <li>
        <a href="#">{{$segment}}</a>
    </li>
    @endforeach
</ol>

But now i am facing issue with the urls. I am getting the current url of the route with all the decendents. Can someone please help me that how can I add links to the breadcrumbs ?

Thanks.

解决方案

If I understand your issue correctly, you just need to fill in the URL of the link. This is untested but I think it should work.

<ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i>Marketplace</a></li>
    <?php $segments = ''; ?>
    @foreach(Request::segments() as $segment)
        <?php $segments .= '/'.$segment; ?>
        <li>
            <a href="{{ $segments }}">{{$segment}}</a>
        </li>
    @endforeach
</ol>

这篇关于带有链接的 Laravel 动态面包屑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆