When a user gets an Access Denied page, how can you use drupal_add_css to load a particular stylesheet? Is this possible?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is possible. The following code can add a CSS file when Drupal returns a access denied page.
Take in mind that when Drupal returns such error, the URL shown in the browser doesn’t change; in example, if I am trying to access
/admin/content, and I am not allowed to access that page, the shown URL doesn’t change. You need to check the headers output from Drupal to verify if it output the access denied header.The equivalent for Drupal 7 is the following one.
The same code can be used for a preprocess function implemented by a theme.