Is it possible to call a function which is located in a controller from a view?
This is what i have in my controller, as an example
function checkKey
Views are not meant to call controller actions. Reverse your logic, call that function in the controller and set it to a variable you sent to the view. Then you can have the if statement check that variable in your view template.
If that doesn't work for you, maybe a helper is what you need: https://www.codeigniter.com/user_guide/general/helpers.html