dklemmt / contao_dk_mmenu

Implementation of mmenu as extension for Contao Open Source CMS
15 stars 16 forks source link

Array issues in php8 #64

Closed Defcon0 closed 2 years ago

Defcon0 commented 2 years ago

Hello,

in the default template mmenu_default a check for a non-existing index is missing. Correct would be:

<?php

$GLOBALS['TL_CSS']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.css|static';

if ($this->options['polyfill'] ?? false) {
    $GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu.polyfill'] = 'bundles/contaommenu/mmenu/mmenu.polyfills.js|static';
}
$GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.js|static';
if ($this->options['drag']['menu']['open'] ?? false) {
    $GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu.hammerjs'] = 'bundles/contaommenu/hammerjs/hammer.min.js|static';
}

?>
<script>
    document.addEventListener(
        "DOMContentLoaded", function () {
            const menu = document.querySelector('#<?= $this->elementId ?>');
            if (null !== menu && 0 === menu.querySelectorAll('li.active').length) {
                const trails = menu.querySelectorAll('li.trail');
                if (0 < trails.length) {
                    trails.item(trails.length - 1).classList.add('active');
                }
            }
            new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>);
        }
    );
</script>

Could ypu please add the fix to the repo? Thanks!

fritzmg commented 2 years ago

Could ypu please add the fix to the repo?

Just provide a PR? ;)

Defcon0 commented 2 years ago

Done ;-) Thought it would be too less for a PR (only 2 lines) ;-)

Defcon0 commented 2 years ago

https://github.com/dklemmt/contao_dk_mmenu/pull/65

rabauss commented 2 years ago

@fritzmg: Should be solved, shouldn't it?