Steps to reproduce:

  1. Fresh install of Drupal 7 + mobile_switch
  2. Configure mobile switch to use Bartik for desktop, Stark for mobile and Seven for administration
  3. Configure mobile switch not to use mobile theme for administration.
  4. Create a new page with a url alias of page-1 and a second page with a url alias of page-administration-page.

When viewing /page-1 on a mobile device, you get Stark, as expected. When viewing /admin, you get Seven, as expected.

When viewing /page-administration-page on a mobile device, you'd expect to get the mobile theme, Stark. Instead, you get the desktop theme, Bartik. Mobile switch identifies that it should hand off the page to the native system theme because it identifies it as an administrative page and the native system theme for this non-admin page is actually Bartik.

Throughout mobile_switch.module, the following is used to identify administrative pages that should use the administrative theme settings:
stristr($_GET['q'], 'admin')

Instead, shouldn't it be something more like this?
path_is_admin(current_path())

(As a real-world use case, this came up on a client site with a staff directory that had an alias of /about/administration, thanks to menu structure and pathauto settings.)

CommentFileSizeAuthor
#1 mobile_switch_admin_path_issue.patch2.8 KBakoepke
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

akoepke’s picture

Assigned: Unassigned » akoepke
Status: Active » Needs review
FileSize
2.8 KB

We have been experiencing frustration with the same bug, here is patch that fixes this issue.

Due to the code running during hook_boot, we can't use the standard Drupal functions like path_is_admin, they are not available. In order to resolve this we have implemented hook_flush_caches and in there we take a copy of the admin paths and put them into a system variable. This provides us access to them without having to have Drupal bootstrapped and fully loaded. The checking of the path is now handled by a helper function _mobile_switch_path_is_admin.