I specificed another frontpage for the mobile useres. This worked on the mobile page. Unfortunatly the same frontpage was now on the dektop version...

I use the same domain and the 'Switch theme for a mobile device' option

CommentFileSizeAuthor
#4 before_save.jpg36.54 KBJonasK
#4 after_save.jpg36.36 KBJonasK

Comments

twom’s picture

Status: Active » Fixed

Hi,

This bug is fixed in the dev version.

I will make a new 2.2 release...

JonasK’s picture

Status: Fixed » Active

Hello Tom

Thank you for your help. I intsalled the new 2.2 release.
Unfortunatly the problem still exists. As soon as I save a default frontpage for the mobile version it automatically overwrites the the default frontpage of the desktop version with tha same value.

twom’s picture

Assigned: Unassigned » twom

Hi,

I am not able to replay this problem. The one thing that can go wrong is that your desktop site is detected as a mobile site. Can you give me the structure of your mobile and desktop url (you don't have to give the exact urls, but is it www.domain.tld and m.domain.tld or www.domain.tld and www.domain.tld/mobile, ...)

JonasK’s picture

StatusFileSize
new36.36 KB
new36.54 KB

As I have seen I can change the default frontpage for the mobile version within the 'mobile tools' section as well as under /admin/settings/site-information. There it seems as the 2 fields are treated as one.

See the attached pictures. I only enter the frontpage for the mobile version but after saving it changes the frontpage of the desktop version with the same value,

The problem might be that my site has the same structure for desktop and mobile version (www.domain.tld)? The theme switching is done by the option 'Switch theme for a mobile device'. Does this not work in the scenario I use?

Thanks for the help!

twom’s picture

Status: Active » Needs review

Hi Jonas,

I removed yesterday a bug that caused wrong detection of the site type in the case of having the same url for desktop as mobile.

Can you try the new code? (the current dev package should work)

JonasK’s picture

Thanks, seems to be better now!

twom’s picture

Status: Needs review » Closed (fixed)

Thx for reporting back!!!

Much appreciated :)

julient’s picture

Version: 6.x-2.1 » 6.x-2.x-dev
Status: Closed (fixed) » Active

Hi,
I was having the same problem. So I installed the latest module version 6.x-2.x-dev and ran the update.
Still, when saving, the mobile front page is overwriting the desktop front page.
My domain URL for desktop and mobile is both dev.domain.tld instead of www.domain.tld like Jonas, does it matter?

ryrye’s picture

Similar issue for me. I've opened another issue at http://drupal.org/node/1145944 for my particular problem, feel free to close if its actually the same as this.

julient’s picture

It could be the same issue. I haven't got an answer yet wether it mattered if the domain was www.domain.tld or dev.domain.tld.
Anyone?

ryrye’s picture

From scanning the code, it looked like it might be dependent on using m. and www. for your subdomains. Maybe someone can confirm? If that is the case, it might be a good idea to request that this be made more obvious in the documentation/config forms.

twom’s picture

Status: Active » Needs review

Hi All,

Probably you all configured the front page settings from the 'admin/settings/site-information' page?

I removed the setting there and just kept it in the mobile-tools configuration page... I guess it is more transparant to keep mobile configurations for now in a centralized space. I hope you can give it another try. It seems to be working for me!

AlexisWilke’s picture

Assigned: twom » Unassigned
Status: Needs review » Active

Hi guys,

The culprit is the $_GET['q'] used at the end of this function:

function mobile_tools_get_redirect_url($destination_site) {
  include_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  $destination_url = ($destination_site == 'mobile') ? variable_get('mobile_tools_mobile_url', '') :  $destination =  variable_get('mobile_tools_desktop_url', ''); 
  // collect query parameters
  if(drupal_is_front_page()) {
    return $destination_url;
  }
  
  $query = array();
  foreach ($_GET as $key => $value) {
    if ($key != 'q') {
      $query[] =  $key . '=' . $value;
    }    
  }
  $query = (count($query) > 0) ? implode('&', $query) : '';
  //create the path and reassemble
  $base = preg_replace('{/$}', '', $destination_url);
  $url = url($base . '/' . $_GET['q'], array('query' => $query));
  return $url;
}

When you define two URLs you write something like this:

http://www.example.com/mobile
http://www.example.com/

The function gets one of those URL at the start:

$destination_url = ($destination_site == 'mobile') ? variable_get('mobile_tools_mobile_url', '') :  $destination =  variable_get('mobile_tools_desktop_url', ''); 

(note: why do you do $destination = ... in the second part?!)

That destination URL is the same as the URL defined in the admin screen, thus for the Desktop it is set to:

http://www.example.com/

Then at the end of the function you do this:

$url = url($base . '/' . $_GET['q'], array('query' => $query));

which puts the /mobile right back at the end of the URL.

If I understand properly, the test:

  if(drupal_is_front_page()) {
    return $destination_url;
  }

is supposed to return before the $_GET['q'] is appended. However, that means you are missing any other parameter. Therefore, that's wrong.

And obviously, it is doubly wrong since it doesn't properly serve its real purpose. You now have TWO front pages and for either one, the $_GET['q'] needs to be ignored.

I'm going to give you a patch that corrects this problem at once.

Talk to you soon.
Alexis Wilke

P.S. twom: your solution (in #12) is not going to fly for 99.9% of the people out there.

AlexisWilke’s picture

Okay... well... actually it won't work except for the front page.

Say you enter these:

http://www.example.com/mobile
http://www.example.com/

and you create a new page, let's say node/123 is created. Assuming you are on your desktop, you go to:

http://www.example.com/node/123

That's good up to here.

Now, I do the same on my iPhone and guess what happens? Yep! I'm sent here:

http://www.example.com/mobile/node/123

And that node doesn't exist...

I guess that concept isn't going to work. So the only way is to use a sub-domain, really. Although in my case all I need is a redirect for the home page. I guess I'll look in a different solution.

Just in case there are my changes:

/**
 * Creation of the redirect url. Special care to create the correct url that will 
 * cause the Global Redirect module not to redirect!  
 */ 
function mobile_tools_get_redirect_url($destination_site) {
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

  $destination_mobile_url = variable_get('mobile_tools_mobile_url', '');
  $destination_desktop_url = variable_get('mobile_tools_desktop_url', '');
  $destination_url = ($destination_site == 'mobile') ? $destination_mobile_url : $destination_desktop_url; 

  // build the query string without the $_GET['q'] entry
  $query = array();
  foreach ($_GET as $key => $value) {
    if ($key != 'q') {
      $query[] =  $key . '=' . $value;
    }
  }

  // create the destination path
  $base = preg_replace('{/$}', '', $destination_url);
  $dest_url = $base . '/' . $_GET['q'];
  if ($dest_url == $destination_mobile_url || $dest_url == $destination_desktop_url) {
    // ignore $_GET[q'] in this case since it would otherwise send us
    // back to the wrong page and generate an infinite redirect loop
    $dest_url = $destination_url;
  }

  return url($dest_url, array('query' => implode('&', $query)));
}

However, the test if ($dest_url == $destination_mobile_url || $dest_url == $destination_desktop_url) is incorrect since one of the destination URLs is going to include a sub-path and $_GET['q'] will be node/123 and not the URL alias.

Good luck.
Alexis

venusrising’s picture

Can someone from Mobile Tools post a documentation page or some how to here if we are to set up a m. subdomain how to direct it etc.
i.e m alias go to http://www.example.com? will this work without issue? Trying to clarify and it is quite unclear. Thanks

DanielWashbrook’s picture

I had a similar problem where my site_frontpage and site_frontpage_mobile were the same. For the record I don't want to use a subdomain, just have a different theme and different front pages.

Noticed in the mobile_tools.module on line 151 there's an if statement

if (mobile_tools_site_type() == 'mobile') {

that seems to return true whether it's desktop or mobile.

I changed the if statement to:

if ($mobile_tools_device['type'] == 'mobile') {

and now it works perfectly.

Are there any negative consequences that I didn't foresee?

Thanks!
Daniel

heyehren’s picture

I have the same problem. The custom home page feature within the mobile tools settings only works for one language. It is possible to switch languages via the language switcher, but all $front_page; style links go to the desktop version homepage in each language. None of the above worked for me and i couldn't find a clean way to fix this issue yet.

twom’s picture

Priority: Normal » Major
heyehren’s picture

Just an update: I have tried the latest dev version, but still have the same problem. I have also replaced the pieces of code as suggested by AperoMedia, but this didn't do the trick either.

I'll describe my problem again:

I used to be able to show a different front page when visiting the site on a mobile device. But something happened and now the auto-detection doesn't work anymore for the custom front page. The theme switching works fine though.

Something else i found is that i can't access the mobile front page on a mobile browser at all, but i can access it from a desktop browser.

For example, i can access the mobile front page on a desktop browser, but if i type in the url of the mobile front page in a mobile browser, i see the url of the mobile front page in the address bar but the browser shows me the desktop front page . . .
Or when i click on the "view mobile site" link on a desktop browser i can see the mobile theme plus the mobile front page without any problems. But if i do the same thing on a mobile browser i see the mobile theme with the ---desktop front page---.

Mobile tools is set to use a sub-domain for the mobile site http://m.mydomain.com/

(I have cleared the browser and Drupal cache each time i made a change as well just to be sure)

I hope this makes all sense. I'd really appreciate any help with this!

Regards,
Stefan

heyehren’s picture

Hi there,

For the ones having trouble with the same issue as i had described above. Here is the solution that worked for me:

Open the mobile_tools.module file.
Comment out line 221
Add this code behind line 239:
$mobile_front = variable_get('site_frontpage_mobile', variable_get('site_frontpage', 'node'));
if (drupal_is_front_page() && (drupal_get_path_alias($_GET['q']) != drupal_get_path_alias($mobile_front))) {
drupal_goto($mobile_front);

geniux’s picture

thanks AperoMedia!

changing

mobile_tools_site_type()

to

$mobile_tools_device['type']

did the trick for me and now I have a homepage for mobile visitors and normal visitors without setting up a subdomain.

One important thing to mention tho: This fix only works with version 6.x-2.2 (http://ftp.drupal.org/files/projects/mobile_tools-6.x-2.2.zip)!!

BarisW’s picture

Kleinermann, it seems you and I have the same problem. Because our problem is not the same as the described in this thread, wouldn't it be better to continue at my issue #1197570: Mobile front page returns desktop front page?

aludescher’s picture

Version: 6.x-2.x-dev » 6.x-2.3

At first I thought I have the same bug, that's why I am posting this here. The block was working for me in 6.x-2.3, but the "View full site" link on the mobile front page was pointing to www.domain.com/mobile-front-page?device=desktop. I didn't like that it was sending visitors to mobile front page in the desktop theme. To change this behavior edit mobile_tools.module around line 167

//$url = url($_GET['q'], array('query' => $query));
$urlpath = (drupal_is_front_page()) ? '' : $_GET['q'];
$url = url($urlpath, array('query' => $query));
gbowman’s picture

#16 worked for me using 6.x-2.x-dev

bcobin’s picture

Can't find a solution here either with dev or with 2.3. Mobile front page view isn't being picked up. Have to disable mobile view now - major drag.

This used to work... now it's gone. :-(

Subscribing...

Toktik’s picture

Same problem.

I have Mobile tools 2.x-dev version installed at this moment.

Device detection and theme switching is working properly. But frontpage for mobiles specified in mobile tools settings, does not work. In mobile version I'm viewing desktop version frontpage.

I'm using m.domain.com for mobile version.

Also I noticed that if I go mobile frontpage URL (which is /mobile), I also receive desktop version frontpage (which is /front).

No one solution works from here.

bcobin’s picture

See possibly "cleaner" thread here: http://drupal.org/node/1197570 - still no sign of a solution...

Toktik’s picture

Status: Active » Closed (duplicate)

Closing this as duplicate of #1197570: Mobile front page returns desktop front page.
We should focus in one thread.

drvdt’s picture

Thanks alot,

My sites are fine with your code.

Thank AperoMedia!

You can try them:

http://tanghuyetap.vn/1?device=desktop
http://tanghuyetap.vn/1?device=mobile

{I had a similar problem where my site_frontpage and site_frontpage_mobile were the same. For the record I don't want to use a subdomain, just have a different theme and different front pages.

Noticed in the mobile_tools.module on line 151 there's an if statement
if (mobile_tools_site_type() == 'mobile') {

that seems to return true whether it's desktop or mobile.
I changed the if statement to:
if ($mobile_tools_device['type'] == 'mobile') {

and now it works perfectly.
Are there any negative consequences that I didn't foresee?

Thanks!
Daniel}

j4’s picture

HI, Which version of mobile tools are you using?

Thanks
Jaya

gunnermultimedia’s picture

I experienced the problem in 7.x-2.x. #16 fixed the issue. Note that the if statement is on line 220 in this version.

benchesters’s picture

Thanks very much Daniel (#16), taken me ages to work this out. Works perfectly for me mob tools version = "6.x-2.4"