0

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?

2
  • 1
    Similar to this question minus the templating? Not sure what you're trying to do but http_response_code() could work... Commented Feb 26, 2016 at 2:55
  • @RitterKnight's suggestion is an option. Can you share some relevant plugin code? Do you have an instance of the template from your plugin?
    – Brad Bell
    Commented Feb 26, 2016 at 3:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.