diff --git a/src/QUI/Menu/MegaMenu.php b/src/QUI/Menu/MegaMenu.php index 5ab78be465ea4c30aa44cacb9ed5487441a2948f..2fe7e20f47d352c3381163e59fd729b17afa75ce 100644 --- a/src/QUI/Menu/MegaMenu.php +++ b/src/QUI/Menu/MegaMenu.php @@ -41,7 +41,7 @@ public function __construct($attributes = []) parent::__construct($attributes); $this->addCSSClass('quiqqer-menu-megaMenu'); - $this->addCSSFile(dirname(__FILE__) . '/MegaMenu.css'); + $this->addCSSFile(dirname(__FILE__).'/MegaMenu.css'); if (!$this->getAttribute('enableMobile')) { return; @@ -68,10 +68,10 @@ public function __construct($attributes = []) */ public function getBody() { - $cache = EventHandler::menuCacheName() . '/megaMenu/'; + $cache = EventHandler::menuCacheName().'/megaMenu/'; $cache .= \md5( - $this->getSite()->getCachePath() . + $this->getSite()->getCachePath(). \serialize($this->getAttributes()) ); @@ -80,9 +80,16 @@ public function getBody() try { $cacheResult = QUI\Cache\Manager::get($cache); - // load css files of controls + // load css files from the controls + $cssFiles = []; + foreach ($cacheResult['subMenus'] as $childControl) { - new $childControl(); + $Instance = new $childControl(); + $cssFiles = \array_merge($cssFiles, $Instance->getCSSFiles()); + } + + foreach ($cssFiles as $cssFile) { + QUI\Control\Manager::addCSSFile($cssFile); } return $cacheResult['html']; @@ -126,7 +133,7 @@ public function getBody() } $result = [ - 'html' => $Engine->fetch(dirname(__FILE__) . '/MegaMenu.html'), + 'html' => $Engine->fetch(dirname(__FILE__).'/MegaMenu.html'), 'subMenus' => \array_unique($this->subMenus) ];