Skip to content

Added twig reference to documentation #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions doc/02-Twig-Integration.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ menu object in the other functions:
{{ knp_menu_render(['main', 'Comments', 'My comments'], {'depth': 2}) }}

{% set item = knp_menu_get('sidebar', ['First section']) %}

{% set breacrumbs_array = knp_menu_get_breadcrumbs_array('main') %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work without #161 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this simply returns an array and #161 is about rendering the array with a renderer class instead of doing it in a template.

```

In some cases, you may want to build the menu differently according to the
Expand Down Expand Up @@ -273,3 +275,21 @@ want.
>**NOTE**
>The built-in templates contains some additional blocks to make it easier
>to customize it when using the inheritance.

Twig integration reference
--------------------------

### Functions

* `knp_menu_get('menuName' [, ['Path', 'To', 'Item'], ['options']])`: retrieve an item of the menu
* `knp_menu_render('menuName' [, ['options'], 'rendererName'])`: render a menu
* `knp_menu_get_breadcrumbs_array('menuName' [, 'subItem'])`: get an array that represent the breadcrubs of the current page (according to the menu)

### Filters

* `knp_menu_as_string(menuNode [, $separator])`: generate a string representation of the menu item

### Tests

* `knp_menu_current`: check if the item is the current one
* `knp_menu_ancestor`: check if the item is the ancestor of a current item