Firefox PHP

Module: Automatic Mobile Template

Posted by Brian Moon 
Re: Module: Automatic Mobile Template
July 01, 2011 09:10AM
Something like the automatic mobile template module? That module does not have a complete check for mobile browsers (which is a hard thing anyway, just see all the initiatives for that), but it provides the basic functionality.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Automatic Mobile Template
July 01, 2011 01:50PM
Quote
Maurice Makaay
Something like the automatic mobile template module? That module does not have a complete check for mobile browsers (which is a hard thing anyway, just see all the initiatives for that), but it provides the basic functionality.

Okay, I see it looks like I asked a really stupid question :)

I was under the impression that the module disabled certain features and even other modules as well. Now I realize you must be inferring that it is the accompanying template provided here that did so, and that when I am finished with my own template and activate the module, it should do specifically what I want it to.

My bad :-)


Robert Angle
Phorum lover, nothing more.
Ruminations
Re: Module: Automatic Mobile Template
July 01, 2011 01:54PM
No.. worse .... I was under the assumption that I was reading the mobile template thread, not the mobile mod thread, so I was simly referring you to the requested mod ;-)


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Automatic Mobile Template
July 14, 2011 02:15PM
The problem is that lang/english.php sets the global language defines

$PHORUM['DATA']['LANG']['NewTopic'] = 'New';

You need to change all of them to something like

$PHORUM['DATA']['LANG']['mod_mobile']['NewTopic'] = 'New';

Then around line 22 in mob_mobile put this code:
Language: PHP
//We are using the mobile template, we use the 'shorter' words.. if (isset($PHORUM['DATA']['LANG']['mod_mobile'])) { foreach ($PHORUM['DATA']['LANG']['mod_mobile'] as $k=>$v) { $PHORUM['DATA']['LANG'][$k]=$v; } }

This is after mod_mobile has figured out it is going to be using the mobile templates.

Nick



Edited 1 time(s). Last edit at 07/14/2011 03:35PM by nvrtis.
Re: Module: Automatic Mobile Template
July 14, 2011 04:58PM
You also need to add 'redirect' as one of the 'allowed' pages.

For some reason, a 'droid uses the redirect page after a post. But Safari/iTouch don't.

Nick
Re: Module: Automatic Mobile Template
July 19, 2011 04:03PM
Note that the module does disable all the header and footer hooks, and does not load javascript or css (all the css is inline in the template).
Re: Module: Automatic Mobile Template
July 19, 2011 04:05PM
Small 'bug'... If you have another mod that runs from 'external', you will get a missing index error for HTTP_USER_AGENT because it isn't set when running from CLI...
Re: Module: Automatic Mobile Template
July 20, 2011 03:17AM
Quote
nvrtis
Note that the module does disable all the header and footer hooks, and does not load javascript or css (all the css is inline in the template).

This is only if you are using the mobile template provide here.

I have just finished my own mobile template, which I did by copying my sites main default template and redesigning it so that it would look good on a mobile phone. This module automatically loads it up when a mobile user visits, complete with the css and all hooks.


Robert Angle
Phorum lover, nothing more.
Ruminations
Re: Module: Automatic Mobile Template
September 02, 2011 04:38PM
I really like this module.

But it seems that the template switch is not performed completely: the DEFINEs in templates/mobile/settings.tpl are not taken into account (e.g. list_pages_shown).

I found out that there is a function phorum_switch_template() in common.php.

So in mods/mod_mobile/mod_mobile.php I tried to replace:
Language: PHP
$PHORUM['template'] = $PHORUM["mod_mobile"]["template"];
by:
Language: PHP
phorum_switch_template($PHORUM["mod_mobile"]["template"]);
And it seems to work now. I just wanted you to know, if maybe it is interesting to put in the next module version.


By the way, FYI I also made the two following changes (suggested in previous posts), that could be of interest.
1) In lang/english.php, I replaced all occurences of:
Language: PHP
$PHORUM["DATA"]["LANG"]
by:
Language: PHP
$PHORUM["DATA"]["LANG"]["mod_mobile"]

2) In mod_mobile.php, just below the template switch I added:
Language: PHP
// Switch to mobile template phorum_switch_template($PHORUM["mod_mobile"]["template"]);   // Integrate mobile specific translations foreach($PHORUM["DATA"]["LANG"]["mod_mobile"] as $k => $v){ $PHORUM["DATA"]["LANG"][$k] = $v; }
(maybe it is better to put $PHORUM["DATA"]["LANG"] = array_merge($PHORUM["DATA"]["LANG"], $PHORUM["DATA"]["LANG"]["mod_mobile"]), I'm not sure)

In this manner, my translations defined in mod_mobile only apply to the mobile template.



Edited 1 time(s). Last edit at 09/02/2011 04:41PM by Bruno.
Re: Module: Automatic Mobile Template
September 03, 2011 09:42AM
Those are all good changes IMO. The switch template is something that I wrote to indeed include all required parts when changing the active template.

Can you maybe zip up your module code and post it in this thread? Others probably find it very useful to have these patched sources available.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login