Hello Rob Loach,

I've been working with Mobile theme on a couple sites for a while now, and thought you might be interested in some of the forks I've patched into it. I'd like to see these integrated into the main module branch, but I know you might have your own ideas after seeing mine.

1. Added a block in the module to allow users to switch from mobile to full if mobile was detected, or a permission is available to a role (more for devs working on site).
2. Added the ability to prevent page cache if a mobile theme should be used, this was required to stop the cached full theme page from being put out.

I hope some of this is helpful!

Comments

robloach’s picture

I like it! What are your thought on this going into a 6.x-2.x branch? Another thing we could do is split those new features into individual issues for the 1.x branch and merge the fork into separate patches.

lance.gliser’s picture

Entirely up to you. I would prefer not to fork the project. I only presented it this way, because of the drastic difference. Reading a patch containing it would have been difficult. If you like any of these feature, I'd say just include them in your next dev as you wish, written to please your style.

Do hold off on using the changes yet. I've recently seen some bad interplay between page cache and mobile theme. I'm trying to hunt it down.

Close this ticket if you've learned all you want. I'm not offering a patch yet, just ideas and possible code to make them work.

lance.gliser’s picture

Right, well. I have an answer about why caching is causing such issue. If a page cache exists and caching is on, most modules, including this one, never even get a chance to fire. I elevated the privalges of the module to run at hook_boot, but it's still not enough. The core process isn't written to support hook_boot disabling page cache.

That leaves the only way to disable the page cache on the fly at hook_boot as hijacking the boot operation. That being a bit unstable, I'm not sure this is a reasonable solution. I've written code to do it, but I'm wary. I adopted the process found here: http://drupal.org/node/875152. If this issue (now listed as a D8 issue) http://drupal.org/node/322104 is ever done, or backported, we can get away without doing this.

I completely understand if you think this is something the mobile theme should NOT involve itself in. If you go that route, it might be best to put a note somewhere in the docs telling people that it's not compatible with page caching, or that they have to patch the core, or hijack boot.

Edited to remove a terrible idea.

lance.gliser’s picture

StatusFileSize
new8.72 KB

Ok. Round two.

I decided that it would be a terrible idea to steal the bootstrap process, instead of just patching a possibly useful feature into core.

So, the small patch for drupal core's bootstrap file is now included in this zip.

It changes the current bootstrap.php cache check from:

 // If there is a cached page, display it.
      if ($cache) 

To:

 // If there is a cached page, display it.
      if ($cache && ( !isset($conf['cache']) || $conf['cache'] == TRUE ) ) 

After that, the module itself can handle things with the included changes in this zip. Remember to remove the hardcoded return in the mobile_theme_is_device_mobile() function after you're done testing it.

So, if you patch core as above, and make this a boostrap module, sites can serve cached main theme pages, with non-cached mobile theme'd pages. Make sure you review the code heavily, I just wrote it and will be testing it out client sites next week!

lance.gliser’s picture

StatusFileSize
new8.72 KB

I've been working with this a bit, and discovered some quirks in the above files that you'll want to know about. I'll attach a rezip.

Lessons:
1. The block that produces the 'mobile site' link, can not attempt to detect and hide itself if a normal browser appears. The page gets cached, without the mobile site link, and you're visitors from mobile to normal, get stuck.
2. If you're going to have a hook_boot, and a hook_init, make sure they set a static variable to avoid rerunning.
3. To use drupal_goto at boot, you must manually include the path.inc and common.inc files.

I've run this on two sites now, and it seems to be working well!

norwegian.blue’s picture

Lance, Rob

I am looking for this functionality for D7.

I tried the patch found here: http://drupal.org/node/1198242 but the block it created for me (applied patch to 7.x-1.2) had links which when selected simply gave a 404.

I'm not very good with php
Any chance of getting this functionality in the D7 version?

lance.gliser’s picture

I'm not going to be developing for or even using this module in the future. For sites with truly unique mobile themes, I've found mobile tools allows me to cache the mobile and regular pages (using a separate subdomain), which is a huge step up. Past that, design has started moving to a responsive nature for me, so switching themes as at all is close to over where I work.

avpaderno’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

I am closing this issue, as Drupal 6 is now not supported.