2017 © Pedro Peláez
 

library klink

Package for easily setting classes for active links

image

kilroyweb/klink

Package for easily setting classes for active links

  • Thursday, February 2, 2017
  • by kilroyweb
  • Repository
  • 1 Watchers
  • 2 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Klink

A simple way to manage active menu items, (*1)

Install

``` bash composer require kilroyweb/klink, (*2)


In config/app.php 'providers': ```php KilroyWeb\Klink\KlinkServiceProvider::class,

In config/app.php 'facades':, (*3)

'Klink'=> KilroyWeb\Klink\Facades\Klink::class,

Usage

Klink must start with the "url" method, from there options can be added as needed, (*4)

Create menu items

<ul>
    {!! Klink::url('my-account')->label('My Account') !!}
    {!! Klink::url('logout')->label('Logout') !!}
</ul>

Results (If on /my-account page), (*5)

<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, (*6)

<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:, (*7)

<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), (*8)

<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:, (*9)

    <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="", (*10)

The Versions

02/02 2017

dev-master

9999999-dev

Package for easily setting classes for active links

  Sources   Download

MIT

by Kilroy Web Development

html link active

02/02 2017

1.0.3

1.0.3.0

Package for easily setting classes for active links

  Sources   Download

MIT

by Kilroy Web Development

html link active

02/02 2017

1.0.2

1.0.2.0

Package for easily setting classes for active links

  Sources   Download

MIT

by Kilroy Web Development

html link active

02/02 2017

1.0.1

1.0.1.0

Package for easily setting classes for active links

  Sources   Download

MIT

by Kilroy Web Development

html link active

28/10 2016

1.0.0

1.0.0.0

Package for easily setting classes for active links

  Sources   Download

MIT

by Kilroy Web Development

html link active