An error page for http://example.com/admin and below is rendered using the admin theme. The error page should be rendered using the site's default theme even if there is a separate admin theme.
It seems strange when you have an admin theme, and different system theme, when some anonymous or authenticated users try to access an admin page which they have no access too, and get a different theme than the one they are currently using.
Since the system will set the admin theme as default on every path that has /admin/* path.
You can see the difference when trying to access an drupal site on a 404 or 403 page on local site which has 2 different theme for the admin and system, just make sure the user you use for testing has been granted the right to "View the administration theme".
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | customerror-drupal6-278575-9.patch | 1.99 KB | maijs |
| #8 | customerror-drupal6-278575-8.patch | 2.06 KB | maijs |
| #5 | 403.png | 107.49 KB | deplifer |
| #5 | 404.png | 109.17 KB | deplifer |
| #4 | customerror.patch | 3.06 KB | kbahey |
Comments
Comment #1
deplifer commentedNew Patches, missing
global $custom_themein the files, for overriding the default theme.Comment #2
kbahey commentedDid you test this?
How is the above code supposed to work? Who will set the variable $theme?
Also, please do not use tabs and revise the code style to conform with Drupal's code style guidelines.
Comment #3
deplifer commentedSorry a typo in the patch it should read>>
For the 5.0 patch the 6.0 patch is as it shoudl be yes teste both v6 and v5 on drupal 6 an5 respectively.
Essentially if system default is selected for both do nothing which resulting in use of the "admin theme" for 403 pages. And the system theme for 404 pages.
Comment #4
kbahey commentedWhy should the 403 have the admin theme by default? This is not backwards compatible with the existing behavior and can be confusing and even ugly for sites that have a nice custom theme but use garland or plain zen for admin.
Also, the code is obscure, which means it is not easy to maintain.
I refactored the D5 version in the attached. Please review and test.
Comment #5
deplifer commentedThanks for the refactoring :-)
I did not mean that all
403pages have theadmin theme.But the default behaviour of drupal is that it uses the
admin themeon the pages havingadminin the start of thepath.Adding a couple of screenshots.
Added a temp site for d6 on my machine the
default themeispushbuttonand theadmin themeisgarland.This is what happens on the pages when accessing 404 and a 403.
Comment #6
Screenack commentedI'd love this feature, and the patch here doesn't apply against the current version.
Comment #7
2farnorth commentedI too would like to see this feature applied, as I use two different themes for admin/non-admin sections.
Comment #8
maijs commentedHere is a patch against 6.x-dev version with code in #1 and #4 combined.
Comment #9
maijs commentedSorry, a revised version of #8. Please review.
Comment #10
plan9 commentedThe patch at #4 no longer works. Is this working in the 5.x dev release?
Comment #11
plan9 commentedJust tested 5.x dev and it doesn't have the patch. I've tried manually applying code from #4 but too much has changed. Does anyone have an old version of custom error from around July, 2008 ? It isn't listed in the previous releases.
Comment #12
kpander commentedI'm just chiming in here to say the patch in #8 works great for me and resolves the 'admin theme on 403/404 pages' issue. Thanks! It'd be great if the patch was incorporated into the module.
Comment #13
kbahey commentedCommitted the patch in #9 to 6.x-1.x-dev. Should be in the tarball in a few hours.
Thanks to all.
Comment #14
plan9 commentedThis isn't fixed for 5.x branch
Comment #15
kbahey commentedI am not maintaining the 5.x branch actively anymore.
However, if someone wants, they could test the patch of 5.x and verify that it is working, or reroll it if it is not, and I will commit it once it is verified working on that branch.
Comment #16
lifer commentedI hope you are still working on this, as I cannot get any of these patches to work for me.
I might be a little green behind my Drupal-ears, but here goes (any understanding and help is deeply appreciated):
After I installed the module I copied the patch to the customerror module folder and opened a console and went to the customerror module path.
Then (for the #8 patch) I ran 'patch customerror.module customerror-drupal6-278575-8.patch' and it responded with:
Hunk #3 succeeded at 165 with fuzz 2 (offset 1 line)
Hunk #4 succeeded at 275 (offset -7 lines)
I get the 'Theme' selection option in '/admin/settings/customerror', but the 403 theme remains the admin theme and NOT the selected theme.
I tried to disable/enable the module as well but it didn't help.
I wonder if there is missing a part somewhere and what it should look like :S
Comment #17
anil614sagar commentedComment #18
gisleSeems nobody (including anil614sagar) is working on this any more. It appears to fixed for D6, so I am changing version. D5 version is no longer maintained. I am not going to spend time on backporting this to D5.
However, if someone wants, they could test the patch of 5.x and verify that it is working, or reroll it if it is not, and I will commit it once it is verified working on that branch.
I'm closing now, but feel free to reopen if you're willing to test the D5 patch.
Comment #19
gisleThis was closed prematurely. This isn't fixed in 6.x after all. Reopening, and changing category to bug report.
Comment #19.0
gisleJust made it clearer what the problem is about.
Comment #21
gisleI am not going to work on issues affecting D6.
Comment #22
acbramley commentedThis is actually still happening on 7.x-1.1, debugging into the customerror_page() function, global $custom_theme is correctly being set above the switch ($code) statement but it is still rendering in the admin theme.
Reproducable by being logged in as an authenticated user, which has permission to view the administration theme and attempting to hit /admin. Works correctly when doing the same thing as an anonymous user without that permission.
Comment #23
gisleThe global
$custom_themethat is used to implement this for the D5 and D6 branches is not used in D7.D7 provides two different mechanisms for overriding the theme:
hook_custom_theme()andtheme callback.However, both are called quite early in the bootstrap process, and the core mechanism that determines what theme to use for pages on the admin path overrides them.
I can't see how to fix this without hacking core or doing something equally nasty. Feel free to reopen if you have a patch that fixes this for D7.
It looks like this is changed for D8: #1954892: Replace 'theme callback' and hook_custom_theme() with a clean theme negotiation system. It is too early to tell, but maybe this can be reopend and fixed for the D8 version?
Comment #24
acbramley commentedDamn that's a shame :( Hopefully someone can come up with a smart solution who has more experience with the core themeing processes. Thanks for the response :)