kilroyweb / klink
易于设置活动链接类别的包
1.0.3
2017-02-02 13:09 UTC
This package is not auto-updated.
Last update: 2024-09-28 20:14:35 UTC
README
#Klink
管理活动菜单项的简单方法
安装
composer require kilroyweb/klink
在 config/app.php 的 'providers' 部分
KilroyWeb\Klink\KlinkServiceProvider::class,
在 config/app.php 的 'facades' 部分
'Klink'=> KilroyWeb\Klink\Facades\Klink::class,
使用方法
Klink 必须以 "url" 方法开始,然后可以根据需要添加选项
创建菜单项
<ul> {!! Klink::url('my-account')->label('My Account') !!} {!! Klink::url('logout')->label('Logout') !!} </ul>
结果(如果在 /my-account 页面)
<ul> <li class="active"><a href="http:///my-account">My Account</a></li> <li><a href="http:///logout">Logout</a></li> </ul>
移除更改或移除 "li" 容器元素
{!! Klink::url('my-account')->label('My Account')->container(false) !!} {!! Klink::url('my-account')->label('My Account')->container('h3') !!}
结果
<a href="https:///my-account">My Account</a> <h3><a href="https:///my-account">My Account</a></h3>
或者当在 "my-account" 页面时
<a href="https:///my-account" class="active" >My Account</a> <h3 class="active"><a href="https:///my-account">My Account</a></h3>
检查多个 URL
{!! Klink::url('my-account')->alsoCheck(['/profile', '/'])->label('My Account') !!}
结果(在 /profile、/ 或 /my-account 页面时)
<h3 class="active"><a href="https:///my-account">My Account</a></h3>
仅输出活动类
有时你有一个自定义链接,只需要将其类设置为活动状态
<ul> <li class="{!! Klink::url('my-account')->showClass() !!}"><a href="http://homestead.app/packages/klink/public/my-account">My Account</a></li> </ul>
在 my-account 页面上将返回 class="active"
,否则将返回空的 class=""