diff --git a/README.md b/README.md index 5d203ea..9c6ecd8 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 +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 +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 +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 +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