contao-thememanager/ctm-push-navigation
Installation
composer require contao-thememanager/ctm-push-navigation
Ensure contao-thememanager/core-bundle is also installed (dependency).
Enable the Bundle
Add to config/bundles.php:
ContaoThememanager\CtmPushNavigationBundle\CtmPushNavigationBundle::class => ['all' => true],
First Use Case: Push Navigation in a Template
Content > Push Navigation).{{ ctm_push_navigation(element) }}
Backend Configuration
Define a Push Navigation Element
Twig Integration
{% if ctm_push_navigation.is_active(element) %}
<button class="ctm-push-trigger">{{ 'CTM_PUSH_TRIGGER'|trans }}</button>
{{ ctm_push_navigation.render(element) }}
{% endif %}
document.querySelector('.ctm-push-trigger').addEventListener('click', (e) => {
e.preventDefault();
ctmPushNavigation.toggle(e.target);
});
Styling with CSS
assets/css/ctm-push-navigation.css:
.ctm-push-navigation {
--ctm-push-bg: #2c3e50;
--ctm-push-transition: all 0.3s ease;
}
Multi-Language Support
{{ 'CTM_*'|trans }} for translatable labels.With Contao Thememanager
With Frontend Frameworks
x-data:
<div x-data="{ open: false }" x-on:click.away="open = false">
<button @click="open = !open">Menu</button>
{{ ctm_push_navigation.render(element, { open: open }) }}
</div>
const PushNavigation = ({ isOpen, onToggle }) => (
<>
<button onClick={onToggle}>Menu</button>
<div className="ctm-push-navigation" style={{ display: isOpen ? 'block' : 'none' }}>
{renderTwig('ctm_push_navigation', { element: elementData })}
</div>
</>
);
AJAX Loading
{{ content::load() }} to lazy-load navigation:
{{ content::load('ctm_push_navigation', { id: element.id, ajax: true }) }}
JavaScript Conflicts
assets/app.js:
document.addEventListener('DOMContentLoaded', function() {
require(['ctm-push-navigation'], function() {
// Initialize after dependencies
});
});
Caching Issues
php bin/contao-console cache:clear
var/log/contao.log for missing assets.Mobile Responsiveness
@media (max-width: 768px) {
.ctm-push-navigation {
width: 100vw !important;
}
}
Menu Hierarchy Limits
max_depth in Twig:
{{ ctm_push_navigation.render(element, { max_depth: 2 }) }}
Backend Logs
config/local.php:
'debug' => true,
'log' => [
'file' => 'var/log/contao.log',
],
CtmPushNavigationBundle errors.Browser DevTools
.ctm-push-navigation class for missing styles.console.log(ctmPushNavigation); // Check if object exists
Custom Animations
ctmPushNavigation.animations.push({
name: 'customSlide',
enter: function(el, done) { /* ... */ },
leave: function(el, done) { /* ... */ }
});
Backend Overrides
CtmPushNavigationWidget to modify the widget template:
// src/Resources/contao/dca/tl_content.php
$GLOBALS['TL_DCA']['tl_content']['config']['onload_callback'][] = function() {
System::loadLanguageFile('tl_content');
$GLOBALS['TL_DCA']['tl_content']['fields']['ctm_push_navigation']['eval']['template'] = 'custom_ctm_push';
};
Event Listeners
ctm.push.navigation.init):
// config/services.yaml
ContaoThememanager\CtmPushNavigationBundle\EventListener\PushNavigationListener:
tags:
- { name: kernel.event_listener, event: ctm.push.navigation.init, method: onInit }
Theme-Specific Config
ThemeManager to load theme-specific JS/CSS:
{% if theme.name == 'dark-theme' %}
{{ ctm_push_navigation.render(element, { theme: 'dark' }) }}
{% endif %}
How can I help you explore Laravel packages today?