Skip to content

Commit

Permalink
Tweaked the new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Feb 18, 2016
1 parent af018e0 commit 84584b3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Configuration/MenuConfigPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ private function normalizeMenuConfig(array $menuConfig, array $backendConfig, $p
$itemConfig['default'] = (bool) $itemConfig['default'];
}

// normalize 'target' option, which allows to open menu items in different windows or tabs
if (!array_key_exists('target', $itemConfig)) {
$itemConfig['target'] = false;
} else {
$itemConfig['target'] = (string) $itemConfig['target'];
}

$menuConfig[$i] = $itemConfig;
}

Expand Down
22 changes: 19 additions & 3 deletions Resources/doc/tutorials/custom-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ easy_admin:
# ...
```

Customizing the Labels and Icons of the Menu Items
--------------------------------------------------

Customizing the Labels, Icons and Targets of the Menu Items
-----------------------------------------------------------

### Labels

Expand Down Expand Up @@ -95,6 +94,23 @@ easy_admin:
# ...
```

### Targets

By default, when clicking on a menu item, the linked resource is displayed in
the same browser tab. If you prefer to open the resource in a new tab or in a
specific HTML frame, define the link target using the `target` option of the
menu item:

```yaml
easy_admin:
design:
menu:
- { entity: 'Product', target: '_blank' }
- { entity: 'User', target: '_parent' }
- { entity: 'Category', target: '_self' }
# ...
```

Customizing the Backend Index Page
----------------------------------

Expand Down
4 changes: 1 addition & 3 deletions Resources/views/default/menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
item.type == 'empty' ? '#' : ''
%}

<a href="{{ path }}"
{% if item.type == 'link' and item.target is defined and item.target is not empty %}target="{{ item.target }}{% endif %}"
>
<a href="{{ path }}" {% if item.target|default(false) %}target="{{ item.target }}"{% endif %}>
{% if item.icon is not empty %}<i class="fa {{ item.icon }}"></i>{% endif %}
{{ item.label|trans }}
{% if item.children|default([]) is not empty %}<i class="fa fa-angle-left pull-right"></i>{% endif %}
Expand Down

0 comments on commit 84584b3

Please sign in to comment.