'']; // Detect current path for active-link highlighting $currentPath = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH); /** * Return 'active' if $href matches the current path, else ''. */ $isActive = fn(string $href): string => str_starts_with($currentPath, $href) ? ' active' : ''; /** * Return 'show' if any child href is active (keeps accordion open on load). */ $groupActive = function (array $children) use ($currentPath): string { foreach ($children as $child) { if (str_starts_with($currentPath, $child)) return ' show'; } return ''; }; // Child paths per collapsible group — used to keep the right group open $weatherChildren = ['/dashboard/weather/']; $cropChildren = [ '/dashboard/crop-analysis/soil-test-data/', '/dashboard/crop-analysis/plant-test-data/', '/dashboard/crop-analysis/water-test-data/', '/dashboard/crop-analysis/animal-dietary-balance/', '/dashboard/crop-analysis/compost-test-data/', ]; $settingsChildren = [ '/dashboard/client-settings/soil-recommendations.php', '/dashboard/client-settings/product-list.php', '/dashboard/client-settings/update-details.php', ]; ?>