Jump to content
TNG Community
eat-sleep-code

Disabling mobile mode via template?

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.

Share this post


Link to post
Share on other sites
bhemph

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.

Share this post


Link to post
Share on other sites
eat-sleep-code

@bhemph any guidance for creating a mod?  Or is it literally just a PHP file that goes in the /mod/ folder and sets $sitever ?

 

Share this post


Link to post
Share on other sites
bhemph

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

Share this post


Link to post
Share on other sites
fluffy82

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!

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites
Ken Roy

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?

Share this post


Link to post
Share on other sites
XerxX

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

Share this post


Link to post
Share on other sites
Ken Roy

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

 

Share this post


Link to post
Share on other sites
XerxX

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

Share this post


Link to post
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!

 

 

Share this post


Link to post
Share on other sites
manofmull

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

I can't remember how to tweak and get it working, I'm not sure whether I need to instal it!

Share this post


Link to post
Share on other sites
Ken Roy
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×