the-cocktail / sulu-megamenu-bundle
Bundle for managing Mega Menus in the Sulu content management system
Installs: 4 853
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 2
Type:sulu-bundle
Requires
- php: >=7.4
- doctrine/doctrine-bundle: ^1.0 || ^2.0
- sulu/sulu: ^2.1
- symfony/config: ^4.3 || ^5.0
- symfony/dependency-injection: ^4.3 || ^5.0
- symfony/http-foundation: ^4.3 || ^5.0
- symfony/http-kernel: ^4.3 || ^5.0
- twig/twig: ^2.0 || ^3.0
Requires (Dev)
- handcraftedinthealps/zendsearch: ^2.0
- jackalope/jackalope-doctrine-dbal: ^1.6
- jackalope/jackalope-jackrabbit: ^1.3
- phpstan/phpstan: ^0.12.18
- phpstan/phpstan-doctrine: ^0.12.10
- phpstan/phpstan-phpunit: ^0.12.6
- phpstan/phpstan-symfony: ^0.12.4
- phpunit/phpunit: ^8.5 || ^9.0
- squizlabs/php_codesniffer: ^3.5
- symfony/browser-kit: ^5.2
- symfony/dotenv: ^4.3 || ^5.0
This package is auto-updated.
Last update: 2025-03-07 14:23:47 UTC
README
Create complex tree menus in Sulu with sections, image items, external url, custom url, etc..
Installation
Add SuluMegamenuBundle in your composer.json:
composer require the-cocktail/sulu-megamenu-bundle
Register the bundle
Register the bundle in your config/bundles.php
:
<?php // config/bundles.php return [ // ... TheCocktail\Bundle\MegaMenuBundle\SuluMegamenuBundle::class => ['all' => true], // ... ];
Update your data with:
bin/console doctrine:schema:update --force
Or execute the following SQL: (recomended: use doctrine migrations to generate diff migration)
CREATE TABLE mm_menuitem (id INT AUTO_INCREMENT NOT NULL, media_id INT DEFAULT NULL, parent_id INT DEFAULT NULL, resource_key VARCHAR(255) NOT NULL, webspace VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, locale VARCHAR(255) NOT NULL, uuid VARCHAR(255) DEFAULT NULL, link VARCHAR(255) DEFAULT NULL, position INT NOT NULL, INDEX IDX_D6C6460BEA9FDD75 (media_id), INDEX IDX_D6C6460B727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB; ALTER TABLE mm_menuitem ADD CONSTRAINT FK_D6C6460BEA9FDD75 FOREIGN KEY (media_id) REFERENCES me_media (id); ALTER TABLE mm_menuitem ADD CONSTRAINT FK_D6C6460B727ACA70 FOREIGN KEY (parent_id) REFERENCES mm_menuitem (id)
Configure the routing
# config/routes/sulu_admin.yaml sulu_megamenu_api: resource: "@SuluMegamenuBundle/Resources/config/routing_api.yaml" type: rest prefix: /admin/api
Configure SuluMegamenu
Add config/packages/sulu_megamenu.yaml
with your desired menus:
sulu_megamenu: menus: header_top: title: 'Header Top' header: title: 'Header' footer: title: 'Footer' footer_bottom: title: 'Footer Bottom'
Permissions
Make sure you've set the correct permissions in the Sulu backend for this bundle!
Settings > User Roles
Twig Functions
sulu_megamenu_render
This function will render the default template
{{ sulu_megamenu_render('header') }}
Custom template as argument
{{ sulu_megamenu_render('header', 'menu/header.html.twig') }}
Additional parameters
{{ sulu_megamenu_render('header', 'menu/header.html.twig', request.webspaceKey, app.request.locale) }}
sulu_megamenu_get
Get items to reuse in diferent context
{% set items = sulu_megamenu_get('header') %} {% include 'menu/desktop.html.twig' %} {% include 'menu/mobile.html.twig' %}
Additional parameters:
{{ sulu_megamenu_get('header', request.webspaceKey, app.request.locale) }}