Thread:Extension talk:MobileFrontend/How Do we make to Mobile view stick?/reply (5)

After quite a few hours of alterations, I came up with a relatively simple fix (in addition to that simple device detection modification above) to make the changed views stick. All of these changes were done to MobileContext.php.

The reason that mobile views would not stick on a desktop device was that the cookie "[mf_mobileFormat]" controlled by function setUseFormatCookie was not being created. This can be fixed by taking this and changing the setcookie function call (lines 420-421 at the time of writing) to this The reason for this was that on my machine, the cookie domain was not properly set. As this is an unnecessary feature, I eliminated it.

Now to make desktop view stick on mobile devices, I changed function toggleVIew to set UseFormatCookie to 'false' if toggled to desktop and changed shouldDisplayMobileView accordingly. Function toggleView was changed to this (notice changed lines are followed by " // MODIFIED!!! " )

This way there is something that can be specifically checked that should stick if the user toggles to desktop on a mobile device.

Now the final part is to change the function shouldDisplayMobileFormat in the following way.

Notice the commented section shows the code to add. This works with our check for wether the user intends to toggle to desktop.

I hope this is helpful.