Jump to content
TNG Community

Disabling mobile mode via template?


eat-sleep-code

Recommended Posts

eat-sleep-code

Is there any possible way to disable the mobile mode completely, either from the config.php or the template.

I am building a new template -- something that looks like at least came from this decade -- and want to disable the mobile mode and design a single responsive layout.  The current setup renders a whole new skin based on the viewport at load time, instead of being responsive if I resize or rotate a window.

I want to do this without modifying the core TNG code as that is just bad practice for future upgrade compatibility.

Link to comment
Share on other sites

The way to do it would be to make a mod to change siteversion to always say standard.  With a mod, you uninstall before upgrade and re-install after upgrade in order to make sure that if only some of the files affected by the mod change you don't end up with a partially installed mod.  You're looking at only one file that would need a change, so it is simpler in that if that file were updated the mod would show as not being installed.

Adding something to the config, would require at least 3 other core TNG files to be modified just to allow you to change any existing settings or modify new ones added after an upgrade.

Link to comment
Share on other sites

I have attached what would be the basic mod.  I looked back and it looks like that file has not changed since at least TNG 10.1.1.  So I made the mod file indicate that following https://tng.lythgoes.net/wiki/index.php?title=TNG_Mod_Version_Numbers_for_Beginners  Then I used https://tng.lythgoes.net/wiki/index.php?title=Mod_Manager_-_Creating_Config_Files and https://tng.lythgoes.net/wiki/index.php?title=Mod_Manager_Syntax to put in the piece identifying the file to modify.  Then I have the part to identify the location within the file that I want to use as an anchor for the modification, which in this case is a replace in order to comment out the existing code that sets $sitever to anything other than standard.  So that gives you a fairly basic mod to follow with looking through the directions for making a mod.  https://tng.lythgoes.net/wiki/index.php?title=Category:Mod_Manager is the entire category on the wiki.  When you create mods, you need to make sure that they are UTF-8 without BOM.  Most mods that are published on the wiki say to back up the files that are changed by the mod before installing so that if the install goes awry and uninstall is not available, you can restore those files and get back to your prior state.  That is generally good advice when developing a mod, since you may miss a refresh and have less stable changes than what someone has tested and published to the wiki.

no_mobile_v10.1.1.0.cfg

Link to comment
Share on other sites

This has saved my life :)

My website (using WordPress, no TNG template) has about 2000 lines of CSS coding to make everything fit together and look like I want. The WordPress pages look fine in every position, but the TNG pages only worked on "pc" and "tablet" mode. The mobile mode was just an incomprehensible rumble, with amongs other problems the menu which I don't use and have coded out of the pages visible again as a bullet list, a huge green rectangle replacing my header image etc. I didn't feel like adding another 500 or so lines of code specifying the same but for mobile mode, so I just ignored it and told everyone not to look at the mobile site 😂

Why didn't I ever think of writing a mod to force TNG to use standard all the time? Great!

Link to comment
Share on other sites

Newfloridian
58 minutes ago, fluffy82 said:

This has saved my life :)

Why didn't I ever think of writing a mod to force TNG to use standard all the time? Great!

I whole heartedly agree with you that mobile mode in general, not just TNG is anathema. I certainly don't write for that format. I do detest the damage that mobile mode does to my own Feature Articles where the banner heading and the left hand column are just exised. I use only TNG's template 4 and over many years have devised a navigation system in the left hand column to guide around the more than 500 fully illustrated articles on site. As a sop, I do put the message "Optimal screen resolution is 1680x1050 and above. Page will display on mobile phones - landscape orientation recommended"

I did have requests from several readers if it was easy to put the website back into standard mode on a mobile phone. I came up with a minor modification to a code snippet which Ron Krzy sent me. This is put in the standard footer and displays a button on a mobile phone which alternates between "Switch to standard site / Switch to mobile site" depending on which view you are looking at. This button does not display on a PC or a tablet. I put the code into a separate small file which is included into footer.php

I guess mobile mode is here to stay. I guess to if there are individuals out there who want to walk down the street not looking where they are going or driving down the freeway at 80 mph with a Big Mac in one hand and a mobile phone in the other, how can I stop them. I wonder too whether there might be an undercurrent here from the great all encompassing Google - I have had several of the listings in their search engine with the message - not mobile friendly added to it. 

Cheers Alan

 

Link to comment
Share on other sites

Has anyone ever tried changing the TNG meta.php file to use

 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 

as recommended on HTML Responsive Web Design on the W3School web site?

Link to comment
Share on other sites

Ken, that line is found in genlib.php:

    if($sitever == "mobile" || $sitever == "tablet") {
        echo "<meta name=\"HandheldFriendly\" content=\"True\" />\n";
        echo "<meta name=\"MobileOptimized\" content=\"320\" />\n";
        echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";

Maybe I'm wrong but I think that line isn't necessary when the site is viewed on a PC?

Please correct me if I'm wrong.

/Erik

Link to comment
Share on other sites

Thanks Erik,

Maybe I should have phrased the question a bit differently.  What happens if the viewport line is applied regardless of whether TNG determines the device is a smart phone and sets $sitever = "mobile" or that the device is a tablet and sets $sitever = "tablet" ?

Note that I was involved in pushing Darrin to add mobile in TNG v10 after spending a month where my only access to the Internet was on my smart phone   I do not believe that browsers supported responsive designs at that time.

I have not looked at the mod to disable $sitever = "mobile" but I suspect that without the viewport statement you will not get a responsive site.  But then I am not a web designer, so I maybe completely wrong

 

Link to comment
Share on other sites

Ken, and all,

If you look at the source code of https://botea.se/botebygden/ovrigt_i_och_runt_botea/stortannsjon.php you can see that it is a top tag and it's always active.

You can start with a big screen desktop and resize the browser to as narrow as you like (450px?) and the content is resizeing and relocating. (This page shows this behaviour clearly if you resize slowly)

It's of course a lot of @media - see the css in the source. (just Find "media")

Please don't ask too difficult questions as I wrote the last version in 2015 and simply handed the site over, incl some administrator training.

HTH

Erik

Link to comment
Share on other sites

eat-sleep-code

@bhemph, I had a little hiccup trying to activate the mod -- which I figured out -- and it works like a charm!   Thanks!

 

 

Link to comment
Share on other sites

1 hour ago, manofmull said:

I cannot instal the mod on TNG11.1.2  due to this error:    line 5: %author tag is unknown

The %author% tag is a TNG v12 Mod Manager tag.  For TNG 10 and 11 that tag needs to be removed from the mod cfg file

Link to comment
Share on other sites

  • 3 years later...

Hi Guys,

I'd love to see it working and see how you did it! I tried for a long time to get my menu to overwrite the default mobile, but continued to show the default. Please share! I can show you what I've done prior in my sandbox if you're interested. I need something that an end-user could easily modify or use.

Thanks a million,

Marsha
Genealogy Web Templates
https://genealogywebtemplates.com

 

Link to comment
Share on other sites

Rob Severijns

I'm not entirely sure if this what you are looking for and if it can be this simple?

in siteversion.php
Change line 1
function getSiteVersion($nomobile = false)

Link to comment
Share on other sites

Hi Cees and Rob,

Does the mod allow for a dropdown menu to show up in mobile or does it allow you to create your own links? Does the original TNG menu show up on non-mobile or is that changed as well? Sorry for all of the questions, but I've haven't used any mods with my templates so the end user can choose what they like.

Rob, I'm thinking that if it were that easy, it would be a miracle! I'll try it later today!

Thanks,
Marsha
Genealogy Web Templates
https://genealogywebtemplates.com

Link to comment
Share on other sites

familyhistoryuk
3 hours ago, Rob Severijns said:

I'm not entirely sure if this what you are looking for and if it can be this simple?

in siteversion.php
Change line 1
function getSiteVersion($nomobile = false)

Rob, this solution is effective. However, the challenge lies in the remaining pages.

My plan is to transform the index.php into a Bootstrap format and proceed from there.

I anticipate that the issue will still persist in the other pages, as TNG is not a dynamic modular application.

This is my initial assessment based on a brief examination of the situation.

Be good to hear any others who's got experience with this?

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...