Hello,
I want to get the method name in the view to display a CSS class based on that.
I have a method like "employees/documents" (Employees - Controller, Documents - method)
In view how i can get the method name "documents" ?, is there any built-in function from codeigniter ?
Right now i created custom_helper.php :
PHP Code:
<?php
if (!function_exists("get_url")) {
function get_url(): string
{
$url = $_SERVER['REQUEST_URI'];
$exp = explode("/", $url);
return $exp[3];
}
}
and in view
Code:
<?php echo (get_url() == 'documents') ? 'active' : ''; ?>
This works !, but if any parameters come witht this url, i need to edit again. is there any alternative way which you can suggest ?