mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
33 lines
945 B
PHP
33 lines
945 B
PHP
<?php
|
|
|
|
if (!function_exists('active_route')) {
|
|
/**
|
|
* Devuelve 'active' si la ruta actual coincide con la proporcionada.
|
|
*
|
|
* @param string $routeName Nombre de la ruta definida en route_to().
|
|
* @return string
|
|
*/
|
|
function active_route(string $routeName): string
|
|
{
|
|
try {
|
|
return current_url() === route_to($routeName) ? 'active' : '';
|
|
} catch (\Exception $e) {
|
|
return ''; // Por si la ruta no existe o lanza error
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!function_exists('active_uri_starts_with')) {
|
|
/**
|
|
* Devuelve 'open active' si uri_string() comienza con el prefijo dado.
|
|
* Útil para marcar menús padres.
|
|
*
|
|
* @param string $prefix Prefijo del URI, como 'config', 'catalogo', etc.
|
|
* @return string
|
|
*/
|
|
function active_uri_starts_with(string $prefix): string
|
|
{
|
|
return str_starts_with(uri_string(), $prefix) ? 'open active' : '';
|
|
}
|
|
}
|