dev-master
9999999-devBreadcrumb builder for Laravel 4
MIT
The Requires
- php >=5.3.0
- illuminate/support 4.1.*
by Chris Sprague
breadcrumb
Breadcrumb builder for Laravel 4
Crumbler is a breadcrumb trail generator for Laravel 4., (*1)
Installation is done with composer., (*2)
Add the following to the composer.json file in your Laravel 4 project., (*3)
"require": { ... "bad-mushroom/Crumbler": "dev-master" },
Next, update Composer:, (*4)
composer update
Now open app/config/app.php
in your Laravel project to add the service provider:, (*5)
'providers' => array( ... 'Badmushroom\Crumbler\CrumblerServiceProvider', ),
In the same file, add the facade alias:, (*6)
'aliases' => array( ... 'Crumbler' => 'Badmushroom\Crumbler\Facades\Crumbler' ),
There are two methods that you'll use., (*7)
To add a breadcrumb to your code use:, (*8)
Crumbler::crumb('Crumb Name', 'uri');
To generate the HTML for the crumb trail:, (*9)
Crumbler::build();
build() takes an optional string parameter for the breadcrumb separator. This can be a single character like '>' or a a line of html like <span class="myClass">::</span>. The default is: <span class="separator">/</span>, (*10)
As an example, in your controller file:, (*11)
// You can add some base breadcrumbs in your constructor. public function __construct() { Crumbler::crumb('1', 'one'); Crumbler::crumb('2', 'two'); } public function yourMethod() { Crumbler::crumb('3', 'three'); $crumbs = Crumbler::build(); return View::make('yourView')->with('crumbs', $crumbs); }
The above example would output the following in your view:, (*12)
<ul class="crumbler"> <li><a href="one">1</a><span class="separator">/</span></li> <li><a href="two">2</a><span class="separator">/</span></li> <li class="active">3</li> </ul>
The last breadcrumb element will be considered the "active" link. You'll also want to add your own css as necessary., (*13)
http://opensource.org/licenses/MIT, (*14)
Breadcrumb builder for Laravel 4
MIT
breadcrumb