Closed (outdated)
Project:
Mobile Tools
Version:
6.x-2.x-dev
Component:
Miscellaneous
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
14 Mar 2011 at 15:35 UTC
Updated:
26 Jun 2020 at 14:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
petersax commentedOk, first time poster on d.o, fresh from drupalcon chi. I'm pretty sure this is going to violate some protocol since I'm actually on 6.x-2.1, but I'm having the same issue and I think I can help, so here goes. If anyone wants to chime in and let me know where this should have gone, please do.
I couldn't find any reference in the module code to a 'mobile' querystring variable. I did find a 'nomobile' in $_GET, with comment "// backwards compatibility with the nomobile parameter," so apparently this is old, but it does work. My [site].com redirects mobile users to m.[site].com. Mobile users going to [site].com/?nomobile=true successfully sets the cookie to redirect to desktop. [site].com/?nomobile=false unsets it, and sends back to m.[site].com.
Important note: sending mobile users who desire deskop to m.[site].com/?nomobile=true (notice the m.) does not work, since it sets a cookie on that domain, then redirects to [site].com where there is no cookie, so it redirects to m.[site].com which redirects back, so we have a redirect loop, which is nobody's idea of a good friggin time.
I tried setting the cookie domain (which my colleague pointed out sounds like cookie dough mane; who wouldn't want one) in settings.php to [site].com so that the cookies are the same and the redirect loop doesn't happen, but I haven't been able to get it to work and I figured my time would be better spent posting long-winded half-solutions on d.o. Bye.
Comment #2
bcobin commentedWell, saxdev, I'm not sure if it's exactly what you intended, but your post helped a lot. I had appended the query directly, without the '/'. With the proper string - it seems to work fine!
I will set this to "fixed" thank you one and all!
Comment #3
bcobin commentedOK - I spoke too soon - yes, you do need the slash, but saxdev, you are right on the money: your solution does work, while the instructions in the current documented do not - at least over here, anyway.
So, for dummies like me, if you're out there, here's what works:
With automatic redirection on (using domain redirection with "m." prefix), send users to the non-mobile site by setting the link to http://[site]/?nomobile=true
To return to mobile site, send users to http://m.[site]/?nomobile=false
Looks like that's working for me. Setting this to "needs review". Thanks a ton for this, saxdev and, of course to twom for a great module! You're all rockstars...
Comment #4
twom commentedHi all,
Thx for the feedback on the module. Currently there is some confusion with the nomobile=true functionality.
Some time ago, I decided to replace that functionality by a more transparent way of controlling the output.
You can now use
This method allows much more flexibility and removes the double negation ?nomobile=false
http://drupal.org/node/459686 - see Force the user to see a specific version of the site (I updated the documentation)
I also removed all references to the ?nomobile method... It is hard to keep backwards compatibility :)
Let me know if you see any other issues, or improvements I can make in the documentation.
Comment #5
bcobin commentedSeems to work nicely! Two small notes:
1. Old code (?mobile=) won't work and will need to be changed - no biggie.
2. I think you have a typo in the second list item; "?device=mobile => force the the device to be recognized as desktop" should be "?device=mobile => force the the device to be recognized as mobile" right?
Thanks, twom - rockin' module!
Comment #6
twom commentedyes, that was a type:
?device=mobile forces the device to be recognized as mobile!
Glad it all works for you!
Comment #8
yang_yi_cn commentedtried the latest dev and still doesn't work.
?device=desktop (try to force desktop version while using a mobile device) works for the first time, but then any link goes to redirection loop
?device=mobile (try to force mobile version when using a desktop) have no effect at all
Comment #9
yang_yi_cn commentedMy problem seems to be caused by the "REQUEST_TIME", this is not defined on my server, so the cookie always expires and never get set.
It looks like this constant is introduced in Drupal 7 but not available in Drupal 6.
I changed it to use "$_SERVER['REQUEST_TIME']", as attached.
Comment #10
venusrising commentedDoes this setting get done in the admin url area? Not sure where to place it.
Comment #11
polHello,
I'm encountering some problems with dev version:
On a desktop:
When I browse my site using ?device=mobile, I see the mobile version as it should.
If I use ?device=desktop, I see the desktop version.
If I use ?device=auto, I see the desktop version.
If I use no argument, I always see the mobile version, even on a desktop computer.
I think there is a problem with the cookie setting, I don't have time to dig up the code right now, but the dev version is clearly not usable. (I took it because I had this bug #1105750: Call to undefined function url())
@yang_yi_cn: I think your patch is now useless, they are using
time()in place of$_SERVER['REQUEST_TIME']in the dev version.Comment #12
cdracars commentedThis issue seems to still be relevant.
Comment #13
minoroffense commentedComment #14
venusrising commentedWe are using the stable version but when clicking on the view full site it goes to the full site unless user clicks a link at which time it takes them back to the mobile site.
Comment #15
mibfire commentedIf "Switch theme based on the URL" is checked then this isnt working.
Comment #16
devin carlson commentedMarked #1632410: Device doing an infinite loop on blackberry devices as a duplicate.
Comment #17
minoroffense commentedComment #18
Cardinals27 commentedour redirections are working perfectly with the ?device= variable. we have links in the footer on our desktop and mobile themes that will allow the user to force-switch the theme ... however ... google has taken it upon themselves to index 3 versions of the same page:
for instance:
http://www.example.com/about-us
http://www.example.com/about-us?device=mobile
http://www.example.com/about-us?device=desktop
are all 3 indexed as separate pages. is there a way to hide the appended variable or some way to prohibit indexing the variabled url?
Comment #19
amarslaksh commentedHi All,
For Drupal 7 I created a custom block and its working fine.. (place the block as per the requirement where u need )...
function mobile_tools_block_view($delta) {
$block = array();
if($delta == "mobile_tools"){
$block['content'] = mobile_tools_block_message();
}
return $block;
}
/**
* Helper function returning the configurable message for the notification
*/
function mobile_tools_block_message() {
$site = _mobile_tools_site_detection();
if ($site == 'mobile' ) {
$output = variable_get('mobile_tools_desktop_url', '');
$output = l(t('View Full Site'),'http://'. $output, array('#theme' => 'theme_default'));
echo $output;
}
else if ($site == 'desktop' ) {
$output = variable_get('mobile_tools_mobile_url', '');
$output = l(t('View Mobile Site'),'http://'. $output, array('#theme' => 'theme'));
echo $output;
}
}
Comment #20
avpadernoI am closing this issue, as it's for a Drupal version no longer supported.