Package Data | |
---|---|
Maintainer Username: | mjanssen |
Maintainer Contact: | dev.marnix@gmail.com (Marnix Janssen) |
Package Create Date: | 2013-06-03 |
Package Last Update: | 2014-11-17 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 03:02:11 |
Package Statistics | |
---|---|
Total Downloads: | 5,850 |
Monthly Downloads: | 16 |
Daily Downloads: | 0 |
Total Stars: | 11 |
Total Watchers: | 3 |
Total Forks: | 5 |
Total Open Issues: | 0 |
** If you have problems running setSeperator (typo'd) after update, I changed the function name to setSeperator.
A small and easy customizable breadcrumb generator for Laravel 4.
Edit your .json file and add the following line to your "require"
"mj/breadcrumb": "dev-master"
After this run the composer update
to update your framework and get the breadcrumb class loaded into your files.
Open app.php in your config folder
Add the line 'Mj\Breadcrumb\BreadcrumbServiceProvider'
to the providers array.
To make use of the Facade that comes with Laravel 4, make sure you register the alias in the file 'app/config/app.php'.
Like this: 'Breadcrumb' => 'Mj\Breadcrumb\Facades\breadcrumb'
To create breadcrumbs use the following code:
Breadcrumb::addbreadcrumb('linkname', 'url');
You can add multiple breadcrumbs by repeating the code above.
To set an seperator you can use:
Breadcrumb::setSeparator('yourseperator')
At last send your breadcrumbs to your template (or just generate them) with the following command:
Breadcrumb::generate()
Note: Use real url's (like /this/page) and not Laravel's URL helper. Not setting a URL at all will also work.
//Controller
public function page()
{
//Those are required to set some breadcrumbs first.
Breadcrumb::addBreadcrumb('home', '/');
Breadcrumb::addBreadcrumb('some page', '/some-page');
Breadcrumb::addBreadcrumb('last piece'); //Does not need a url because it's the last breadcrumb segment
Breadcrumb::setSeparator('/'); //Set some seperator you think is nicest (not required)
$data = array(
'breadcrumbs' => Breadcrumb::generate() //Breadcrumbs UL is generated and stored in an array.
)
//return the view with the $data array to use it in the view
return View::make('some/page', $data);
}
//View
{{$breadcrumbs}} // -> UL with list-items with the links :)