Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lavary committed Feb 10, 2016
1 parent e15641a commit 9a089f8
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ __For Laravel 4.x, check [version 1.5.0](https://github.com/lavary/laravel-menu/
- [Controller Actions](#controller-actions)
- [HTTPS](#https)
* [Sub-items](#sub-items)
* [Set Item's ID Manualy](#)
* [Set Item's Nicknames Manualy](#)
* [Referring to Items](#referring-to-items)
- [Get Item by Title](#get-item-by-title)
- [Get Item by Id](#get-item-by-id)
Expand Down Expand Up @@ -348,6 +350,55 @@ It is possible to add sub items directly using `parent` attribute:
?>
```

## Set Item's ID Manually

When you add a new item, a unique ID is automatically assigned to the item. However, there are time when you're loading the menu items from the database and you have to set the ID manually. To handle this, you can call the `id()` method against the item's object and pass your desired ID:

```php
<?php
// ...
$menu->add('About', array('route' => 'page.about'))
->id('74398247329487')
// ...
```

Alternatively, you can pass the ID as an element of the options array when adding the menu item:

```php
<?php
// ...
$menu->add('About', array('route' => 'page.about', 'id' => 74398247329487));
// ...
```

## Set Item's Nickname Manually

When you add a new item, a nickname is automatically assigned to the item for further reference. This nickname is the camel-cased form of the item's title. For instance, an item with the title: `About Us` would have the nickname: `aboutUs`.
However there are times when you have to explicitly define your menu items owing to a special character set you're using. To do this, you may simply use the `nickname()` method against the item's object and pass your desired nickname to it:

```php
<?php
// ...
$menu->add('About', array('route' => 'page.about'))
->nickname('about_menu_nickname');

// And use it like you normally would
$menu->item('about_menu_nickname');

// ...
```

Alternatively, you can pass the nickname as an element of the options array:

```php
<?php
// ...
$menu->add('About', array('route' => 'page.about', 'nickname' => 'about_menu_nickname'));

// And use it like you normally would
$menu->item('about_menu_nickname');
// ...
```

## Referring to Items

Expand Down

0 comments on commit 9a089f8

Please sign in to comment.