I wondered if we could embellish from this answer?
I'm developing a plugin where at some point it needs to detect if the user is currently on one of the error pages (400, 403, 404, 500, or 503).
I'm not sure of any built in methods within craft, so I figured an easier solution would be to just check the file name being used. Php's __FILE__
method refers to the .php file it was called from. I can't seem to grasp how to use getTemplateName()
within a plugin.
Is there a better way to detect the error page, or a clean way of detecting the template file being used?
http_response_code()
could work...