Fatal error: Call to undefined function mobile_tools_switch_menu_link() in [...]/sites/all/modules/mobile_tools/mobile_tools.module on line 198

I got this error when enabling the mobile switch block.

this function actually doesn't exist.

ps: If someone knows how to construct the path for the links I could create a custom block waiting the fix.

Comments

martinar’s picture

Priority: Normal » Critical

I'm getting the same error:
Fatal error: Call to undefined function mobile_tools_switch_menu_link() in [...]/sites/all/modules/mobile_tools/mobile_tools.module on line 192.
I need to fix this error asap to use the mobile version of my site.
Any help is appreciated.

Thank you in advance

roborn’s picture

Status: Active » Needs review
StatusFileSize
new1.71 KB

I got the same error.

Here's a patch to fix this issue.

minoroffense’s picture

Status: Needs review » Needs work

EDIT: Seems as though /mt/ is something special. However it doesn't do the redirect properly even with the patch above (at least for me). I'll have to do some more digging.

The patch provided hard codes the URL pattern into the links. It doesn't take the actual mobile URL configuration into account.

You would need to load the mobile_tools_mobile_url variable and mobile_tools_desktop_url variable to build the links.

I would suggest something like this.

/**
 * Create the url to go to the desktop/mobile version
 */
function mobile_tools_switch_menu_link($site, $path, $options) {
  $url = '';
  switch($site) {
    case 'mobile':
      $url = variable_get('mobile_tools_mobile_url');
      break;
    case 'desktop':
    default:
      $url = variable_get('mobile_tools_desktop_url');
    
  }
  return url($url . '/' . $path, $options);
}

Unless the /mt is a special URL that causes a redirect of some kind that I'm not aware of.

minoroffense’s picture

StatusFileSize
new1.92 KB

See above

minoroffense’s picture

My patch isn't the right solution. Switching back to need works.

minoroffense’s picture

Assigned: Unassigned » minoroffense
StatusFileSize
new2.19 KB

Here's a new patch. I think the issue of not redirecting for me using the original patch is related to some logical errors later on the the code.

Your patch does add the right code to fix the issue. I'll open/check for another issue to fix the other problem.

I've uploaded a new patch with the changes in place plus some extra doc comments.

minoroffense’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.98 KB

Oops, wrong patch file...ugh it's been a long day...

Here's the correct one.

jtwalters’s picture

Patch from #7 seems to work, however, when I try to go *back* to the desktop version, I get this error:

Recoverable fatal error: Argument 1 passed to drupal_http_build_query() must be an array, string given, called in /Library/WebServer/Documents/dev/includes/common.inc on line 2161 and defined in drupal_http_build_query() (line 472 of /Library/WebServer/Documents/dev/includes/common.inc).

minoroffense’s picture

Status: Reviewed & tested by the community » Needs work
slucero’s picture

StatusFileSize
new2.14 KB

This patch is a rebuild of the patch from comment #7. It has a minor adjustment to account for the issues reported in comment #8.

minoroffense’s picture

Status: Needs work » Needs review

I'll review the patch and apply it to a new unstable release later today.

alive2000’s picture

I confirm that the patch #10 works as expected

scottAtRoot802’s picture

Priority: Critical » Normal

I've applied this patch and I'm happy to say it works with one exception. Everything is working as it should on the iPhone, Andriod and Blackberry devices. However, there remains one small bug for me on the iPad. It's possible the bug I'm experiencing is not directly related this bug / patch, but then again the root of this issue is alluding me. If it is appropriate to open a separate issue, I'm happy to do so.

The issue I'm having is this. On an iPad, the site detects a mobile device and shows the correct mobile theme, however the iPad is not redirected to the mobile url as I've configured Mobile Tools to do. This is the first red flag. The site functions fine, until you click on the link to switch from the mobile to desktop version. Actually, since you are still at the desktop url, the link says "View mobile website" even though you are already viewing the mobile theme. Clicking on that link takes you to the mobile url / theme and the link then changes to "View desktop website". Clicking on that takes me to a "Sorry, you can not access this page" at the desktop url even though the destination seems correct "/mt/desktop/node/5". Node 5 is the home page. This is red flag #2. I should also mention that the theme never switches, it remains on the mobile theme no matter what I do. Changing the url path to something else doesn't help. Not that I expected it to help but I had to try.

Beyond this, I have no further clues what's causing the issue. There are no reported errors. It's not clear to me whether this is directly related this bug / patch, if my configuration is incorrect, if there is a redirection issue or something else.

To give you a clearer picture, I have the following configuration:

  • I'm using the Mobile Tools module for Device Detection
  • "Switch theme based on the URL" is enabled
  • "Enable filter for this device group" is checked for all devices and the mobile theme is selected
  • "Enable automatic redirection of the mobile user" is also checked under Redirection Options

I'm using my own custom mobile theme which is integrated with jquery mobile. For those that a familuar with jquery mobile, the links for mobile theme switching have data-role=none and data-ajax=false. There should be no interference from jquery mobile and my tests prove this to be the case. Of course, at this point I haven't ruled out anything.

I made a slight modification to the mobile tools module by adding "Kindle" to list of detected mobile devices in _mobile_tools_device_groups() and _mobile_tools_is_mobile_device() functions. The addition or exclusion of this modification seems to have no effect on the issue I'm having with the iPad.

Again, everything work perfectly for every other device I've tested (iPhone, Galaxy S Andriod, Kindle Fire, and a Blackberry). This issue appears to be isolated to the iPad. If anyone can can give me some guidance with this one I would greatly appreciate it. Thanks.

Patricia_W’s picture

I tried to apply the patch #10 but my patch reports that all hunks fail:
Hunk #1 FAILED at 145.
Hunk #2 FAILED at 200.
Hunk #3 FAILED at 846.

I am attempting to apply the patch to:
version = "7.x-2.x-dev"
core = "7.x"
project = "mobile_tools"
datestamp = "1323822840"

I'm using the patch program on Mac OS X 10.7

Any suggestions?

Patricia_W’s picture

I got around this problem by applying the patch code manually since none of the line numbers matched. No idea why because I was using the correct version. I tried both versions and neither matched.

indigoxela’s picture

Version: 7.x-2.x-dev » 7.x-2.0-unstable1

Hi,
function mobile_tools_switch_menu_link() is also missing in mobile_tools version 7.x-2.0-unstable1 (datestamp = "1319659535").
This is leading to a fatal error, when trying to save new content:
PHP Fatal error: Call to undefined function mobile_tools_switch_menu_link() in /var/www/.../modules/mobile_tools/mobile_tools.module on line 199

As a quick fix I inserted
function mobile_tools_switch_menu_link() {}
in mobile_tools.module, but of course links in mobile switch block don't work.

brandy.brown’s picture

the patch in #10 worked for me. However, I left off the last two lines on the patch because it forced a syntax error.

minoroffense’s picture

Version: 7.x-2.0-unstable1 » 7.x-3.x-dev
Status: Needs review » Closed (fixed)

This issue was fixed in a previous commit and has been moved to the 7.x-3.x branch.

The issue is also fixed in the 6.x-2.x branch.