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".

Comments

deplifer’s picture

StatusFileSize
new2.45 KB
new1.78 KB

New Patches, missing global $custom_theme in the files, for overriding the default theme.

kbahey’s picture

Status: Active » Needs work

Did you test this?

  $custom_theme = variable_get('customerror_' . $error_code . '_theme', ($error_code == 403 ? variable_get('admin_theme', 0) : 0));
  if (!empty($theme)) {
    $custom_theme = $theme;

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.

deplifer’s picture

StatusFileSize
new2.44 KB

Sorry a typo in the patch it should read>>

  $theme = variable_get('customerror_' . $error_code . '_theme', ($error_code == 403 ? variable_get('admin_theme', 0) : 0));
  if (!empty($theme)) {
    $custom_theme = $theme;
  }

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.

kbahey’s picture

Status: Needs work » Needs review
StatusFileSize
new3.06 KB

Why 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.

deplifer’s picture

StatusFileSize
new109.17 KB
new107.49 KB

Thanks for the refactoring :-)

I did not mean that all 403 pages have the admin theme .

But the default behaviour of drupal is that it uses the admin theme on the pages having admin in the start of the path.

Adding a couple of screenshots.
Added a temp site for d6 on my machine the default theme is pushbutton and the admin theme is garland.

This is what happens on the pages when accessing 404 and a 403.

Screenack’s picture

I'd love this feature, and the patch here doesn't apply against the current version.

2farnorth’s picture

I too would like to see this feature applied, as I use two different themes for admin/non-admin sections.

maijs’s picture

StatusFileSize
new2.06 KB

Here is a patch against 6.x-dev version with code in #1 and #4 combined.

maijs’s picture

StatusFileSize
new1.99 KB

Sorry, a revised version of #8. Please review.

plan9’s picture

The patch at #4 no longer works. Is this working in the 5.x dev release?

plan9’s picture

Just 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.

kpander’s picture

I'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.

kbahey’s picture

Version: master » 6.x-1.x-dev
Status: Needs review » Fixed

Committed the patch in #9 to 6.x-1.x-dev. Should be in the tarball in a few hours.

Thanks to all.

plan9’s picture

This isn't fixed for 5.x branch

kbahey’s picture

Status: Fixed » Patch (to be ported)

I 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.

lifer’s picture

I 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

anil614sagar’s picture

Assigned: Unassigned » anil614sagar
gisle’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Assigned: anil614sagar » Unassigned
Status: Patch (to be ported) » Closed (won't fix)
Issue tags: +Needs backport to D5

Seems 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.

gisle’s picture

Title: Custom themes on Error Pages » Admin theme is used on error pages below /admin
Version: 5.x-1.x-dev » 6.x-1.2
Assigned: Unassigned » gisle
Category: feature » bug
Status: Closed (won't fix) » Active

This was closed prematurely. This isn't fixed in 6.x after all. Reopening, and changing category to bug report.

gisle’s picture

Issue summary: View changes

Just made it clearer what the problem is about.

  • Commit 8379ccf on 6.x-1.x, 8.x-1.x by kbahey:
    #278575 by deplifer, maijs: custom themes on error pages
    
    
gisle’s picture

Assigned: gisle » Unassigned
Issue summary: View changes

I am not going to work on issues affecting D6.

acbramley’s picture

Version: 6.x-1.2 » 7.x-1.1
Issue tags: -Needs backport to D5

This 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.

gisle’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

The global $custom_theme that 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() and theme 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?

acbramley’s picture

Damn 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 :)