Skip to content
This repository was archived by the owner on Oct 18, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,39 @@ Breadcrumbs::register('page', function($breadcrumbs, $page) {

### 2. Choose/create a template to renders the breadcrumbs

You have two options to set the view used by the render method:

- Config option:

You can override the config option `breadcrumbs::view` with the dot notation to whatever view you like.

(run `php artisan config:publish DaveJamesMiller/laravel-breadcrumbs`)

- Runtime option:

You can set the view at runtime using

```php
Breadcrumbs::setView('path.to.view');
```

There are two presets already included in this package:

#### Twitter Bootstrap 2

By default, a
[Twitter Bootstrap v2](http://getbootstrap.com/2.3.2/components.html#breadcrumbs)-compatible
unordered list will be rendered.


#### Twitter Bootstrap 3

A [Twitter Bootstrap v3](http://getbootstrap.com/components/#breadcrumbs)-compatible
list can be rendered by adding this line to `app/breadcrumbs.php`:

```php
Breadcrumbs::setView('breadcrumbs::bootstrap3');
```
list can be rendered by using the key `laravel-breadcrumbs::bootstrap3`.

#### Custom template

If you want to customise the HTML, create your own view file (e.g.
If you want to customise the HTML, set the view to the dot notation path to your view (eg. `_partials.breadcrumbs`), and create your own view file (e.g.
`app/views/_partials/breadcrumbs.blade.php`) like this:

```html+php
Expand Down Expand Up @@ -124,13 +139,6 @@ breadcrumb is an object with the following keys:
* `first` - `true` for the first breadcrumb, `false` otherwise
* `last` - `true` for the last breadcrumb, `false` otherwise

Then add this line to `app/breadcrumbs.php`, adjusting the view name as
necessary:

```php
Breadcrumbs::setView('_partials/breadcrumbs');
```

### 3. Output the breadcrumbs in your view

Finally, call `Breadcrumbs::render()` in the view template for each page,
Expand Down
2 changes: 1 addition & 1 deletion src/DaveJamesMiller/Breadcrumbs/BreadcrumbsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BreadcrumbsManager {

protected $environment;

protected $view = 'breadcrumbs::bootstrap';
protected $view;

protected $selectedName;
protected $selectedArgs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public function register()
{
$this->app['breadcrumbs'] = $this->app->share(function($app)
{
return new BreadcrumbsManager($app['view']);
$breadcrumbs = new BreadcrumbsManager($app['view']);

$breadcrumbs->setView($app['config']['laravel-breadcrumbs::view']);

return $breadcrumbs;
});
}

Expand All @@ -34,7 +38,7 @@ public function register()
*/
public function boot() {
// Register the package so the default view can be loaded
$this->package('davejamesmiller/breadcrumbs');
$this->package('davejamesmiller/laravel-breadcrumbs');

// Load the app breadcrumbs if they're in app/breadcrumbs.php
if (file_exists($file = $this->app['path'].'/breadcrumbs.php'))
Expand Down
5 changes: 5 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return array(
'view' => 'laravel-breadcrumbs::bootstrap',
);