digithis/activehelper

Active helper is a simple active state system for your links in laravel 4

Installs: 2 957

Dependents: 0

Suggesters: 0

Security: 0

Stars: 16

Watchers: 6

Forks: 2

Type:helper

dev-master 2013-11-21 08:57 UTC

This package is not auto-updated.

Last update: 2024-04-22 13:37:18 UTC


README

##Active Helper active helper is a simple active state system for your links in laravel 4 ###How to install Add the following line in your composer.json

"digithis/activehelper": "dev-master"

Then run composer update

In app/config.app.php, add the following line to the providers array

'Digithis\Activehelper\ActivehelperServiceProvider',

In the aliases array, add the following line

'Active'  => 'Digithis\Activehelper\ActiveFacade',

###How to use Create a link and its current state :

echo Active::link('users', URL::to('users'), 'Show all users');

This means that if the current request is users, class for link is .active

Add several more routes as a first parameter :

echo Active::link(array('users', 'user/add', 'user/edit'), URL::to('users'), 'Show all users');

Use * as a pattern or exclude routes with not: :

echo Active::link(array('user*','not:user/edit'), URL::to('users'), 'Show all users');

This means that if the request begins with user but is not user/edit, class for link is .active

Set your own attributes if you wish:

echo Active::link(array('group*','not:groups*'), URL::to('group'), 'Show group', array('id' => 'mycustomid'));

You can also only get the current state (boolean)

$state = Active::is('page*','not:pages*');

And return the active class if the routes are matched

Active::classes('page*', 'not:pages*');

// Returns 'active'