Skip to content

Commit

Permalink
Typo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kkiernan authored and Kelly Kiernan committed Feb 15, 2017
1 parent a5121b8 commit e70db84
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Easy Breadcrumb Generation

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Install](#install)
- [Usage](#usage)
- [Dynamic Crumbs](#dynamic-crumbs)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Install

First, install the package via composer:
Expand All @@ -8,7 +18,7 @@ First, install the package via composer:
composer require kkiernan/breadcrumbs
```

Then add the service provider and alias to `config/app.php`.
If using Laravel, add the service provider and alias to `config/app.php`.

```php
'providers' => [
Expand All @@ -22,19 +32,14 @@ Then add the service provider and alias to `config/app.php`.

## Usage

In your controller, add breadcrumbs as needed before rendering the view.
Add breadcrumbs as needed before rendering your view:

```php
public function create()
{
Breadcrumbs::add('Posts', action('PostsController@index'));
Breadcrumbs::add('New Post');

return view('posts.create');
}
Breadcrumbs::add('Posts', action('PostsController@index'));
Breadcrumbs::add('New Post');
```

You can also add many breadcrumbs at one time if you prefer:
Add many breadcrumbs at once if you prefer:

```php
Breadcrumbs::addMany([
Expand All @@ -43,40 +48,38 @@ Breadcrumbs::addMany([
]);
```

The package contains a default Bootstrap view that you can use to display your breadcrumbs. Simply add the following to your layout:
A Bootstrap partial is included to display your breadcrumbs. If using Laravel Blade, you can include the partial in your template:

```
@include('kkiernan::breadcrumbs');
```

Publish this view to `resources/views/vendor/kkiernan` by running the artisan command below. You can then edit the view as desired.
If you'd like to edit the partial, publish it to `resources/views/vendor/kkiernan`:

```
php artisan vendor:publish --tag=kkiernan
```

## Dynamic Crumbs

You may also render breadcrumbs dynamically. This is helpful when there are multiple ways to arrive at a view. For example, imagine that both a list of posts and a dashboard link to a post detail view.
Breadcrumbs can be added dynamically, which is helpful when multiple pages link to a particular page. For example, imagine that both a dashboard and a list of posts link to a post detail view. Consider the following Laravel-centric example in which the first breadcrumb will render as either "Dashboard" or "Posts" depending on the referring page.

```php
// In your DashboardController@index method...
// DashboardController@index...
Breadcrumbs::put('posts', 'Dashboard', action('DashboardController@index'));
```

```php
// In your PostsController@index method...
Breadcrumbs::put('posts', 'Dashboard', action('DashboardController@index'));
// PostsController@index...
Breadcrumbs::put('posts', 'Posts', action('DashboardController@index'));
```

```php
// In your PostsController@show method...
// PostsController@show...
Breadcrumbs::addDynamic('posts');
Breadcrumbs::add($post->title);
```

The breadcrumbs will now display as either "Dashboard / The Post Title" or "Posts / The Post Title". This functionality is also available as `Breadcrumbs::addIf('posts')` for situations where it reads more fluently (usually when the dynamic crumb is not in the first position).

If you need to unset a dynamic crumb and prevent it from rendering, simply call the forget method:

```php
Expand Down

0 comments on commit e70db84

Please sign in to comment.