I'm trying to build my first mobile site, so I'm learning a bit and I might have done something wrong. But I do think I ran into a bug. I'm a big fan of Display Suite so I was happy to see that Mobile Tools has support for Display Suite, but with Mobile Tools enabled (and the Display Suite support) I somehow get

for all nodes, for all User-Agents.

I'll try to find out why it's doing that but some help about where to look would be highly appreciated.

CommentFileSizeAuthor
#1 mobile_tools_static_ds_fix.patch752 bytesokokokok

Comments

okokokok’s picture

StatusFileSize
new752 bytes

I thought it might have something to do with cache so I turned that off, but it's still acting weird.

This seems a relevant piece of code:

function mobile_tools_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'load' && mobile_tools_site_type() == 'mobile' && variable_get('mobile_tools_enable_build_mode', 0)) {
$node->build_mode = 'mobile';
}
}

So I suspected a problem with mobile_tools_site_type().
I added a static caching around it and now things work as expected!

function mobile_tools_site_type() {
  static $site_type = NULL;

  if ($site_type != NULL) {
    $site_detection = variable_get('mobile-tools-site-type-detection', 'mobile_tools');
    drupal_load('module', $site_detection);
    if ($site_detection == 'mobile_tools') {
      $site_type = _mobile_tools_site_detection();;
    }
    else {
      $site_type = module_invoke($site_detection, 'is_mobile_site');
    }
  }
  return $site_type;
}
okokokok’s picture

Title: Mobile tools + Display Suite: buildmode-mobile regardless of User-Agent » Mobile tools + Display Suite: buildmode-mobile regardless of User-Agent => fix for mobile_tools_site_type
Status: Active » Needs review
okokokok’s picture

Oops. This was working better but it was wrong. I noticed the problem when I actually wanted to start using the buildmode-mobile.
The condition should be:

if ($site_type != NULL) {

minoroffense’s picture

Is the above code correct? If so I can apply it as a patch.

devin carlson’s picture

Status: Needs review » Closed (fixed)