kilroyweb/klink
Composer 安装命令:
composer require kilroyweb/klink
包简介
Package for easily setting classes for active links
README 文档
README
#Klink
A simple way to manage active menu items
Install
composer require kilroyweb/klink
In config/app.php 'providers':
KilroyWeb\Klink\KlinkServiceProvider::class,
In config/app.php 'facades':
'Klink'=> KilroyWeb\Klink\Facades\Klink::class,
Usage
Klink must start with the "url" method, from there options can be added as needed
Create menu items
<ul>
{!! Klink::url('my-account')->label('My Account') !!}
{!! Klink::url('logout')->label('Logout') !!}
</ul>
Results (If on /my-account page)
<ul>
<li class="active"><a href="http://localhost/my-account">My Account</a></li>
<li><a href="http://localhost/logout">Logout</a></li>
</ul>
Remove change or remove "li" container element
{!! Klink::url('my-account')->label('My Account')->container(false) !!}
{!! Klink::url('my-account')->label('My Account')->container('h3') !!}
Results
<a href="http://localhost/my-account">My Account</a> <h3><a href="http://localhost/my-account">My Account</a></h3>
Or when on the "my-account" page:
<a href="http://localhost/my-account" class="active" >My Account</a> <h3 class="active"><a href="http://localhost/my-account">My Account</a></h3>
Check Multiple URLs
{!! Klink::url('my-account')->alsoCheck(['/profile', '/'])->label('My Account') !!}
Results (when on the /profile, /, or /my-account pages)
<h3 class="active"><a href="http://localhost/my-account">My Account</a></h3>
Output only the active class
Sometimes you have a custom link where you just need to set the class as active:
<ul> <li class="{!! Klink::url('my-account')->showClass() !!}"><a href="http://homestead.app/packages/klink/public/my-account">My Account</a></li> </ul>
Will return class="active" on the my-account page, otherwise will return empty class=""
统计信息
- 总下载量: 112
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-28