Steps to reproduce:
- Fresh install of Drupal 7 + mobile_switch
- Configure mobile switch to use Bartik for desktop, Stark for mobile and Seven for administration
- Configure mobile switch not to use mobile theme for administration.
- Create a new page with a url alias of
page-1
and a second page with a url alias ofpage-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.)
Comment | File | Size | Author |
---|---|---|---|
#1 | mobile_switch_admin_path_issue.patch | 2.8 KB | akoepke |
Comments
Comment #1
akoepke CreditAttribution: akoepke commentedWe 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.