From f471ca5fd1eaa7bc72d4456a2fbffb89bcdc41de Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 11 Jun 2026 22:18:23 -0500 Subject: [PATCH] fix: set menu_icon param for submenu items to render icons Joomla 6's mod_menu only renders the img column as an icon span for level 1 items. For level 2+ items, the menu_icon param in the JSON params column is used instead. Set this param on both new and existing submenu items so icons render correctly. --- source/script.php | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/source/script.php b/source/script.php index 3c79849..689e702 100644 --- a/source/script.php +++ b/source/script.php @@ -341,19 +341,22 @@ class Pkg_MokoSuiteBackupInstallerScript { $submenus = [ [ - 'link' => 'index.php?option=com_mokosuitebackup&view=dashboard', - 'title' => 'COM_MOKOJOOMBACKUP_SUBMENU_DASHBOARD', - 'img' => 'class:home', + 'link' => 'index.php?option=com_mokosuitebackup&view=dashboard', + 'title' => 'COM_MOKOJOOMBACKUP_SUBMENU_DASHBOARD', + 'img' => 'class:home', + 'menu_icon' => 'icon-home', ], [ - 'link' => 'index.php?option=com_mokosuitebackup&view=backups', - 'title' => 'COM_MOKOJOOMBACKUP_SUBMENU_BACKUPS', - 'img' => 'class:database', + 'link' => 'index.php?option=com_mokosuitebackup&view=backups', + 'title' => 'COM_MOKOJOOMBACKUP_SUBMENU_BACKUPS', + 'img' => 'class:database', + 'menu_icon' => 'icon-database', ], [ - 'link' => 'index.php?option=com_mokosuitebackup&view=profiles', - 'title' => 'COM_MOKOJOOMBACKUP_SUBMENU_PROFILES', - 'img' => 'class:cog', + 'link' => 'index.php?option=com_mokosuitebackup&view=profiles', + 'title' => 'COM_MOKOJOOMBACKUP_SUBMENU_PROFILES', + 'img' => 'class:cog', + 'menu_icon' => 'icon-cog', ], ]; @@ -390,15 +393,26 @@ class Pkg_MokoSuiteBackupInstallerScript } foreach ($submenus as $submenu) { + $params = json_encode(['menu_icon' => $submenu['menu_icon']]); + // Check if this submenu item already exists $query = $db->getQuery(true) - ->select('COUNT(*)') + ->select($db->quoteName('id')) ->from($db->quoteName('#__menu')) ->where($db->quoteName('client_id') . ' = 1') - ->where($db->quoteName('link') . ' = ' . $db->quote($submenu['link'])); + ->where($db->quoteName('link') . ' = ' . $db->quote($submenu['link'])) + ->setLimit(1); $db->setQuery($query); + $existingId = (int) $db->loadResult(); - if ((int) $db->loadResult() > 0) { + if ($existingId > 0) { + // Update params on existing item to ensure menu_icon is set + $query = $db->getQuery(true) + ->update($db->quoteName('#__menu')) + ->set($db->quoteName('params') . ' = ' . $db->quote($params)) + ->where($db->quoteName('id') . ' = ' . $existingId); + $db->setQuery($query); + $db->execute(); continue; } @@ -419,6 +433,7 @@ class Pkg_MokoSuiteBackupInstallerScript $table->component_id = $componentId; $table->client_id = 1; $table->img = $submenu['img']; + $table->params = $params; $table->language = '*'; $table->access = 1;