I'm currently building a mobile theme for my site. I'm going to have a different frontpage for the mobile site. Other than that though, everything will work off the same site (url's etc). Any chance you can add a check box that redirects based on the frontpage only? So, if they visit my site with a mobile device it will redirect them to the mobile site url (which is the same except for a different path). This currently works except then when they click on any link it redirects them again as it sees them as being on the desktop site.

The theme switching part of this works great for what I'm needing. Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

twom’s picture

Assigned: Unassigned » twom
Status: Active » Needs review

Hi,

I just added something experimental. In the settings page you can enter on which pages you only want to redirect. Maybe this feature can help you?

It's is committed to the dev version of the module.

Let me know if this works for you!

Tom

jwbuzz’s picture

I think this should help. I'll give it a try. Thanks

jwbuzz’s picture

I gave this a try. It wasn't working so I updated to the newest release. Now, the "redirect only on the listed pages" option is gone. Any specific reason why you removed that? That's exactly what I need. I only want to redirect from /frontpage.

twom’s picture

Hi,

I currently still see the option to only redirect on certain pages. Can you check again if you have the latest module?

You will see:
exception type:
Do not redirect from the following pages
Do only redirect from the following pages

Tom

jwbuzz’s picture

I'm attaching screenshots of my version as well as the configuration screen. Am I missing something?

jwbuzz’s picture

I just updated to the latest dev release and it has the option now. I'll keep testing.

jwbuzz’s picture

In testing this.. I believe there is still some problem. I think it's still redirecting on every page, but only when it's a mobile device. If I manually switch my theme over to the mobile theme and hit it via a desktop browser, everything works fine. When I hit it from the mobile device, it redirects properly from /frontpage to /m/frontpage. However, when I click on any of my menu items it's doing some redirection still. So, for example, it's supposed to send me to mysite.com/my_view and it's actually sending me to mysite.com/m/frontpage/my_view. I can't ever leave the frontpage now.

It's very difficult for me to debug this since it's only happening from the mobile device. If you can make some suggestions on how to debug or if you can help with the problem, I would appreciate it. I have my settings set to "only redirect on the following pages" with a value of frontpage.

jwbuzz’s picture

Ok.. I hacked mobile_tools_is_mobile_device() to always return true basically so I could force it to think I was on a mobile device even coming from my desktop browser. This allowed me to attach the debugger. In doing so, I think there is a bug on line 434. The original code reads like this:

if (variable_get('mobile_tools_redirect_exceptions', 0) == 'only-redirect') {

I believe you are using the wrong variable name here and the code should read like this:

if (variable_get('mobile_tools_redirect_exceptions_type', 0) == 'only-redirect') {

In essence, the code within that conditional is never being executed and mobile_tools doesn't think I've chosen the only-redirect exception type and thus redirects on every single page. I've made the change locally and can confirm that it works though I haven't tested it thoroughly. I'd be glad to submit a patch if you want me to or if you have time to make the change for dev release since it's a typo.

Please advise..

jwbuzz’s picture

Status: Needs review » Needs work

Upon further testing, I believe the above fix is still needed, but I think there's some additional work needed. The value of $page_match is true a few lines down so the redirect is never happening. Trying to figure out why.

jwbuzz’s picture

Ok.. $_GET['q'] isn't set when you hit the front page so $page_match is always false for it. My change above makes $page_match = true. My change is valid for every page but the front page and still corrected a bug. However, I've added some additional code to line 434 so that it doesn't get executed for the front_page.

if (isset($_GET['q']) && variable_get('mobile_tools_redirect_exceptions_type', 0) == 'only-redirect') {

Can someone closer to the project verify my logic? It works for me, but I can't test all the cases for the module.

x_v’s picture

Title: Mobile front page instead of mobile site » Redirect to mobile front page instead of mobile site sub page
Version: 6.x-1.11 » 6.x-1.12

I installed mobile tools, and tested it with Firefox User Agent Switcher, and all is working great. However, my mobile site only has 1 page (asking user to submit a form specifically for mobile use), so anybody with a mobile device hitting my site like this: site.com/about-us will be redirected to site.mobi/about-us, which will throw a 404.

Is there a way to tell the Mobile Tools module to always redirect to the mobile's version home page? in other words: site.com/about-us redirects to site.mobi

Thanks for any useful input!

deverman’s picture

We seem to have successfully made exceptions for our pages so that none of our sub pages are redirected anymore only our front page is using this exceptions field.

zeth’s picture

Category: feature » support

Hello,

I have the same question as thexman. I'd like to send all mobile users of the site to the mobile home page, rather than create a second, mobile-based version of all pages. Anybody find a way to do this yet?

ransomweaver’s picture

I have a theme that uses jqtouch to implement a single page mobile site. Basically my page.tpl.php lays out my page with all the jqtouch javascript and html, uses a specific menu supplied by drupal to source the table-row navigation, and uses jquery ajax to get the node content from drupal using the services module. There are no page loads after the first visit to the mobile url, just $().load()
It actually ignores anything in the url after the base_url, so you could link into a page and it would append #home after that and all is well. separate themes for desktop and mobile obviously.

larryhackman’s picture

Thanks for this jwbuzz, it did the trick for me! This'll work until someone patches this (fingers crossed).

DanChadwick’s picture

Version: 6.x-1.12 » 6.x-2.x-dev
Category: support » bug
Status: Needs work » Needs review

This is not fixed in 6.x-2.x-dev, dated March 24, 2011 (latest as of this writing). Redirection works, except for the <front>.

To reproduce the bug, set up to Redirect ONLY from <front>. Point browser at your site (with no path). Set the mobile url to www.example.com/mobile.

In mobile_tool_device_redirect, you'll see two executions:
The first time, $_GET['q'] is not set. However, if drupal_bootstrap were called, it would have been set to the normal desktop front page (e.g. node/xxxx perhaps). This path will match <front>.
The second time will have $_GET[q] set to the mobile front page.

Therefore, the fix is to change line 182 of mobile_tools.module from:

  if(isset($_GET['q']) && $pages != '') {

to just

  if($pages != '') {

because in the case of the front page, $_GET['q'] isn't initialized to the front page path until after drupal_bootstrap();

attheshow’s picture

Status: Needs review » Patch (to be ported)
FileSize
668 bytes

This change worked correctly for me when using "exception type" "Do only redirect from the following pages" . I'm correctly redirected from the front page to the mobile site URL, but not on other pages. This is the behavior I was looking for. Submitting a patch for this just in case it helps.

Jens Peter’s picture

I have succesfully installed the mobile tool and all seem to work fine.
I am making a site where we have all the same pages on both normal browsers and mobile browsers except the front page.

The front page is set up with one for desktop browser (standard drupal) and one for mobile as a setting in the mobile tool module.

My problem is that since I use all the tools for the normal site I also use the primary menu.
On this there is a link to "forside" that is the danish name for front.

I get to the mobile front page when I open the site but if I try to get back to the front page using the menu, I get to the desktop front page (/forside) and not the mobile one (/mobilforside).
I use a sub-domain for my mobile site like m.domain.dk.

Please advise as the version I use is newer than the patch above so I am not sure it is a good idea to try and patch it like that.

attheshow’s picture

Status: Patch (to be ported) » Fixed

I see this patch has been applied to version 2.3 of the module. Thanks twom! Marking this issue as fixed.

attheshow’s picture

Status: Fixed » Needs work
FileSize
700 bytes

Wow, I just realized my patch is completely backwards. Must have done my diff in the wrong direction. So this is not fixed. Sorry. I apologize for being a moron. :)
Attaching a corrected patch against version 2.3.

richardhayward’s picture

We installed this patch on Mobile Tools 6.x-.2.3, but we found that the redirects for other pages to our mobile site became disabled after applying the patch. Does this patch specify that the home page and only the home page can be redirected, and no other redirects will operate? We have applied another patch to enable multiple individual page redirects. This would be a good fix to implement in the next release of Mobile Tools.

minorOffense’s picture

Status: Needs work » Needs review

Has the patch from #20 been tested? Does it resolve the issue?

minorOffense’s picture

Assigned: twom » Unassigned