diff --git a/admin/pages/menus.php b/admin/pages/menus.php
index 8245169c..e4ff205f 100644
--- a/admin/pages/menus.php
+++ b/admin/pages/menus.php
@@ -82,21 +82,25 @@ if (isset($_POST['template'])) {
return;
}
- if (isset($_GET['reset_colors'])) {
- if (isset($config['menu_default_color'])) {
- Menu::where('template', $template)->update(['color' => str_replace('#', '', $config['menu_default_color'])]);
- success('Colors has been reset.');
- }
- else {
- warning('There is no default color defined, cannot reset colors.');
- }
- }
-
if (!isset($config['menu_categories'])) {
echo "No menu categories set in template config.php.
This template doesn't support dynamic menus.";
return;
}
+ if (isset($_GET['reset_colors'])) {
+ foreach ($config['menu_categories'] as $id => $options) {
+ $color = $options['default_links_color'] ?? $config['menu_default_color'] ?? '#ffffff';
+ Menu::where('template', $template)->where('category', $id)->update(['color' => str_replace('#', '', $color)]);
+ }
+
+ $cache = Cache::getInstance();
+ if ($cache->enabled()) {
+ $cache->delete('template_menus');
+ }
+
+ success('Colors has been reset.');
+ }
+
$title = 'Menus - ' . $template;
?>
@@ -143,12 +147,13 @@ if (isset($_POST['template'])) {
if (isset($menus[$id])) {
$i = 0;
foreach ($menus[$id] as $menu):
+ $color = (empty($menu['color']) ? ($cat['default_links_color'] ?? ($config['menu_default_color'] ?? '#ffffff')) : '#' . $menu['color']);
?>
-
+
display('admin.menus.js.html.twig', array(
'menus' => $menus,
'last_id' => $last_id,
- 'menu_default_color' => $config['menu_default_color'] ?? '#ffffff'
));
?>
toArray();
});
- $menus = array();
+ $configMenuCategories = config('menu_categories');
+ $configMenuDefaultColor = config('menu_default_color');
+
+ $menus = [];
foreach($result as $menu) {
- $link_full = strpos(trim($menu['link']), 'http') === 0 ? $menu['link'] : getLink($menu['link']);
- $menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link'], 'link_full' => $link_full, 'blank' => $menu['blank'] == 1, 'target_blank' => ($menu['blank'] == 1 ? ' target="blank"' : ''), 'color' => $menu['color']);
+ if (empty($menu['link'])) {
+ $menu['link'] = 'news';
+ }
+
+ $link_full = (str_starts_with(trim($menu['link']), 'http') ? $menu['link'] : getLink($menu['link']));
+ $target_blank = ($menu['blank'] == 1 ? ' target="blank"' : '');
+
+ $color = (empty($menu['color']) ? ($configMenuCategories[$menu['category']]['default_links_color'] ?? ($configMenuDefaultColor ?? '')) : $menu['color']);
+ $color = str_replace('#', '', $color);
+ $style_color = (empty($color) ? '' : 'style="color: #' . $color . '"');
+
+ $menus[$menu['category']][] = [
+ 'name' => $menu['name'],
+ 'link' => $menu['link'], 'link_full' => $link_full,
+ 'blank' => $menu['blank'] == 1, 'target_blank' => $target_blank,
+ 'color' => $color, 'style_color' => $style_color,
+ ];
}
- $new_menus = array();
+ $new_menus = [];
/**
* @var array $configMenuCategories
*/
- $configMenuCategories = config('menu_categories');
if($configMenuCategories === null) {
return [];
}
diff --git a/system/templates/admin.menus.js.html.twig b/system/templates/admin.menus.js.html.twig
index e511c6de..95bd696c 100644
--- a/system/templates/admin.menus.js.html.twig
+++ b/system/templates/admin.menus.js.html.twig
@@ -1,9 +1,16 @@