vrai
This commit is contained in:
parent
1b8bde8bbd
commit
a339153a8d
|
|
@ -10,21 +10,44 @@ $_SESSION['firstLevelMenu'] = $activeLink;
|
||||||
$companyDisplayName = htmlspecialchars($_SESSION['nomSociete'], ENT_QUOTES);
|
$companyDisplayName = htmlspecialchars($_SESSION['nomSociete'], ENT_QUOTES);
|
||||||
$imgData = $_SESSION['photoAssureCrypte'] ?? '';
|
$imgData = $_SESSION['photoAssureCrypte'] ?? '';
|
||||||
|
|
||||||
// Détection automatique des menus actifs
|
// Détection automatique des menus actifs - VERSION CORRIGÉE
|
||||||
$activeParentId = null;
|
$activeParentId = null;
|
||||||
$activeChildId = null;
|
$activeChildId = null;
|
||||||
|
|
||||||
foreach ($menus as $key0 => $menuParent) {
|
foreach ($menus as $key0 => $menuParent) {
|
||||||
$menuChildrenLevelOne = $gabary->get_menus_by_parent_code($menuParent['vue']);
|
$menuChildrenLevelOne = $gabary->get_menus_by_parent_code($menuParent['vue']);
|
||||||
|
|
||||||
foreach ($menuChildrenLevelOne as $key1 => $menuChild) {
|
// 1. Vérifier si c'est un lien DIRECT (comme "Accueil")
|
||||||
if ((explode('/', $menuChild['lienMenu'])[0] ?? '') == $activeLink) {
|
if (empty($menuChildrenLevelOne)) {
|
||||||
|
// Menu sans enfants = lien direct
|
||||||
|
$parentLink = explode('/', $menuParent['lienMenu'])[0] ?? '';
|
||||||
|
if (!empty($parentLink) && $parentLink == $activeLink) {
|
||||||
$activeParentId = $key0;
|
$activeParentId = $key0;
|
||||||
$activeChildId = $key1;
|
break;
|
||||||
break 2;
|
}
|
||||||
|
}
|
||||||
|
// 2. Vérifier les SOUS-MENUS (enfants)
|
||||||
|
else {
|
||||||
|
foreach ($menuChildrenLevelOne as $key1 => $menuChild) {
|
||||||
|
$childLink = explode('/', $menuChild['lienMenu'])[0] ?? '';
|
||||||
|
if ($childLink == $activeLink) {
|
||||||
|
$activeParentId = $key0;
|
||||||
|
$activeChildId = $key1;
|
||||||
|
break 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CORRECTION IMPORTANTE : Si c'est "Accueil" et pas trouvé, c'est menu 0
|
||||||
|
if ($activeParentId === null && $activeLink == 'Accueil') {
|
||||||
|
$activeParentId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toujours avoir une valeur
|
||||||
|
if ($activeParentId === null) {
|
||||||
|
$activeParentId = 0;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user