fix: sidebar marca activo solo el item actual, no todos los de erp.php
This commit is contained in:
@@ -34,17 +34,23 @@ $_current_script = basename($_SERVER['PHP_SELF']);
|
|||||||
*/
|
*/
|
||||||
$_isActive = function (string $route) use ($_current_script): string {
|
$_isActive = function (string $route) use ($_current_script): string {
|
||||||
if ($route === '') return '';
|
if ($route === '') return '';
|
||||||
// Para rutas como /lab_domicilios.php: comparar con basename
|
$parsed = parse_url($route);
|
||||||
$routeBase = basename(parse_url($route, PHP_URL_PATH) ?? '');
|
$routeBase = basename($parsed['path'] ?? '');
|
||||||
if ($routeBase === $_current_script) {
|
|
||||||
|
// Rutas ERP con query params: comparar script Y cada param de la ruta
|
||||||
|
if (!empty($parsed['query'])) {
|
||||||
|
$uriParsed = parse_url($_SERVER['REQUEST_URI'] ?? '');
|
||||||
|
if ($routeBase !== basename($uriParsed['path'] ?? '')) return '';
|
||||||
|
parse_str($parsed['query'], $routeParams);
|
||||||
|
parse_str($uriParsed['query'] ?? '', $uriParams);
|
||||||
|
foreach ($routeParams as $k => $v) {
|
||||||
|
if (($uriParams[$k] ?? null) !== $v) return '';
|
||||||
|
}
|
||||||
return ' active';
|
return ' active';
|
||||||
}
|
}
|
||||||
// Para rutas con parámetros ERP (?m=&v=): comparar con REQUEST_URI
|
|
||||||
$uri = $_SERVER['REQUEST_URI'] ?? '';
|
// Rutas directas como /lab_domicilios.php
|
||||||
if ($route !== '/' && str_contains($uri, ltrim($route, '/'))) {
|
return $routeBase === $_current_script ? ' active' : '';
|
||||||
return ' active';
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Título del sidebar: prioridad al nombre definido por el módulo, luego el genérico
|
// Título del sidebar: prioridad al nombre definido por el módulo, luego el genérico
|
||||||
|
|||||||
Reference in New Issue
Block a user