Skip to content

Commit

Permalink
Merge pull request KnpLabs#245 from KnpLabs/clarify-current-as-link
Browse files Browse the repository at this point in the history
improve documentation for renderer
  • Loading branch information
dbu authored Jul 1, 2016
2 parents e51a31a + 54e9e0a commit e849f84
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions doc/01-Basic-Menus.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ $renderer = new ListRenderer(new Matcher());
echo $renderer->render($menu, array('compressed' => true));
```

Note: You can customize the rendering by extending the `ListRenderer` and
overwrite some of its methods. If you use the [TwigRenderer](02-Twig-Integration.markdown), you can overwrite
templates. Or you can provide your own implementation of the `RendererInterface`.

Working with your menu tree
---------------------------

Expand Down Expand Up @@ -232,7 +236,7 @@ the second argument to the `render()` method:
* `depth`
* `matchingDepth`: The depth of the scan to determine whether an item
is an ancestor of the current item.
* `currentAsLink` (default: `true`)
* `currentAsLink` (default: `true`): Whether to render the "current" menu item as link or as span.
* `currentClass` (default: `current`)
* `ancestorClass` (default: `current_ancestor`)
* `firstClass` (default: `first`)
Expand All @@ -257,6 +261,10 @@ the `li` around that item, as well as a `current_ancestor` around any of
its parent `li` elements. This state can either be forced on the item by
setting it explicitly or matched using several voters.

By default, the current item is rendered as link too. You can make the current
item not a link by setting the `currentAsLink` option to false. The ListRenderer
then renders the item with a `<span>` tag instead of an `<a>`.

```php
<?php

Expand Down Expand Up @@ -318,4 +326,4 @@ Change the charset

```php
$renderer = new ListRenderer(new Matcher(), [], 'ISO-8859-1');
```
```

0 comments on commit e849f84

Please sign in to comment.