, (*1)
Simple Menu Bundle adds Menu to your Symfony application and is integrated with Sonata Admin., (*2)
This bundle depends on SonataAdminBundle and DoctrineExtensions, (*3)
, (*4)
Documentation
Installation
1. Add to composer.json to the require
key, (*5)
composer require kunicmarko/simple-menu-bundle "v1.0.0-beta"
2. Register the bundle in app/AppKernel.php
, (*6)
$bundles = array(
// ...
new KunicMarko\SimpleMenuBundle\SimpleMenuBundle(),
);
Add Gedmo Tree extensions mappings and if you are not using auto_mapping add bundle mappings, (*7)
# app/config/config.yml
orm:
entity_managers:
default:
mappings:
#...
SimpleMenuBundle: ~
gedmo_tree:
type: annotation
prefix: Gedmo\Tree\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
alias: Gedmo
is_bundle: false
3. Update database, (*8)
app/console doctrine:schema:update --force
4. Clear cache, (*9)
app/console cache:clear
5. Install assets, (*10)
app/console assets:install
How to use
In your twig template you can render it with:, (*11)
{{ simple_menu_render('machine_name', level) }}
or if you want to render it on your own you can:, (*12)
{% set menu = simple_menu_fetch('machine_name', level) %}
Override template
You can override default template from config:, (*13)
# app/config/config.yml
simple_menu
template:
render: SimpleMenuBundle:Menu:render.html.twig