|
|
Mobilebot: Joomla Goes Mobile!Posted by Jorge Pablos on 08/21/2009 in Mobile Website , Joomla Plug-ins |
The way a website should look and behave in a mobile device is significantly different than how it does on a laptop or desktop display. We came up with a plug-in for Joomla! to make it easy to instantiate different interfaces depending on the client platform.
We’ve been working on a site redesign that requires significantly different templates for laptops/desktops and mobile displays. On the one hand, we want to optimize the UI for each device; on the other, we don’t want to force users to maintain multiple copies of every page. That would be disgustingly inefficient, particularly for a site based on Joomla!
Instead, wouldn’t it be beautiful to have all sorts of custom templates for each mobile platform and have the appropriate template selected automatically?
A Plug-in Is Born
I started “googling” around and ended up in the Joomla Core-Enhancements Mobile Section. I found three extensions (good) but they all had significant limitations (not so good). For example, one of them required a Joomla! “core” change. Not pretty.
One plug-in in particular captured my attention, the PDA-plugin for Joomla 1.5. This plug-in came pretty close to what I was looking for because 1) it detects all popular mobile platforms and 2) switches Joomla! to a specified mobile template (i.e., this template can also be downloaded with the plug-in).
Unfortunately, even though it came close it still had some shortcomings,
- You can’t handle multiple, independent device/templates with it (i.e., you can’t have one template for iPhone, another for Blackberry, etc).
- You can’t make custom adjustments to your final HTML code based on the device detected (e.g., remove a particular DIV block for the iPhone or a particular OBJECT element for a Blackberry, etc).
- Finally, the detection strings are not easily configurable from the plug-in parameters.
I’m a curious person, so I looked at the plug-in’s source code. A few hours later a new little monster was born (taddah!): the Mobilebot for Joomla 1.5+ plug-in. Here’s a summary of what this plug-in does,
- It can detect iPhone, Blackberry, Android and Opera Mini separately and load a particular template for each of them.
- It has two extra spaces so you can add your own custom mobile devices.
- You can adjust your final HTML code with simple/regular expression PHP replacements; this can be done independently for each particular device.
- If none of the specific devices is detected (or you just have one template for all mobiles), the plug-in can also perform a general mobile detection and load a “generic” mobile template if configured accordingly.
This plug-in uses two detection methods,
- Compare the user-agent HTTP header with a list of strings (all of them configurable)
- Detect a named subdomain in the address bar assigned by you for that particular device
It can even use both methods at the same time. Here’s an example:
Let’s assume that you assign the subdomain http://iphone.example.com for the iPhone template and you enable both detections methods for such devices in the Mobilebot parameters.
If you receive a visit of someone using an iPhone, this is what happens:
- If the visitor types in http://iphone.example.com directly, then subdomain-based detection is triggered and the visitor gets the correct template. In this case, user-agent detection is disregarded.
- If the visitor reaches the site using http://www.example.com, then subdomain based detection doesn’t trigger but the visitor gets the correct template anyway because user-agent detection is enabled too.
The only difference between these two cases is the URL showing in the address bar. In the first case it will show http://iphone.example.com, and http://www.example.com in the second case. If this is not what you want, keep reading.
You may have a reason to keep a consistent URL showing in the iPhone visitor’s address bar. For example,
- You want to get the word out regarding the existence of your mobile subdomain.
- You just are a consistency freak (like yours truly)

Either way, you can accomplish this by enabling the “Redirect to iPhone subdomain” feature along with user-agent detection. In the configuration dialog, each platform has its own “Redirect to mobile subdomain” parameter.
With this configuration, user-agent detection is used as a secondary helper only to correct the URL when needed. Otherwise, the redirection option is turned off by default because it’s not needed by most people. However, if you need it, you can turn it on easily.

Version 1.0
This is the first version of the plug-in so if you find any issues with your particular environment or specific configuration, please, help me correct them. We can accomplish more together!
No mobile template is included with this release. This plug-in has the primary objective of giving you the freedom to have completely independent templates for mobile devices. You can get started with the “PDA” template provided by Denis Ryabov (aka., Physicist) with the PDA-plugin (you may need to do some adjustments to it).
Using this approach, you can include very device-specific HTML markup without affecting the default behavior of your website!
I hope this plug-in helps somebody out there. It certainly will be helpful for us at Nearsoft and new site layout we’re working on. Come back here with your iPhone in about a month and you’ll see what I mean.
Final Setup Notes
If the template you provide for a particular device doesn’t exist, no template change is performed. This is a good thing, for example, if you mistype the template name in the plug-in configuration parameters. Your site won’t break. It will not look right for that device, but it won’t break.
Subdomain-based detection requires some extra configuration. Continuing with the example, both http://www.example.com and http://iphone.example.com should point to the same IP address (e.g., your website) so you may need to do some DNS configurations first.
TweetBacks (Tweet this post)
Trackback(0)
TrackBack URI for this entryComments (67)
Show/hide comments
Awesome
The idea sounds awesome :-) :-D
Thanks a million for the effort in extending the previous applications of its kind.
I will definately let you know if there is some configuration issues
Thanks again
Tjad
Alguna template neutra seria bienvenida
Lo que seria ideal es que tu mismo desarrollaras algunas templates neutrs, para portales de noticias, con un menu principal y poco mas....
Gracias por tu esfuerza
...
PDA Template
"Check PDA plugin" from Yes (default) to No, you can do this in the backend:
Extensions -> Template Manager -> pda
Or as another visitor suggested you can edit the PDA Template and remove or comment out the following lines at the beginning of index.php:
if( $this->params->get( 'checkbot' ) &&
( !isset($GLOBALS['pdabot']['version']) || $GLOBALS['pdabot']['version']!='J100' ) )
die('Inconsistency between versions of PDA-plugin and PDA-template.');
I hope this helps, cheers!
Excellent
Would it be possible in a future revision add an option to choose a different landing page for each device, alongside the template?
One question...
If I create a subdomain, what content should I put in there? I mean, if I create a subdomain I have an empty web without any content, so what happens after the user is redirected to that subdomain, cause there is nothing? Or am I completely wrong??? Hope anybody can help...
TEMPLATE ISSUE
my ploblem is where can i get your template?
i install PDA-plugin in advance.
there is a "PDA" template in my site.
i can't find the default template "mobile".
so, can you help me?
...
The subdomain should be pointing to the same Website, for this you need to make some DNS configurations in your hosting, in other words if you go to www.example.com and subdomain.example.com you should get the same Joomla! Website, then you configure the plugin to tell apart and change the template when the subdomain is detected in the visitor's address bar.
SKY:
The "mobile" template you mention is just the default name we defined for that particular field, it doesn't exist, you need to create your own mobile templates and install them.
I'm sorry we couldn't include a template with this release, you can find a basic template at:
http://joomup.com/blog/2007/10...joomla-15/
You will need to make some simple adjustments to it so you can use it with Mobilebot (please read my prior answer).
I hope we can offer new mobile templates with our plugin in the near future.
duda
...
Exmaples of php blocks
Is there any preset 'receipes' we could adapt to our sites? I noticed your mobile version of nearsoft has a menu link at the top of the page, I was wondering how you added this on the mobile site yet excluded it from the full site. It appears you can only omit content from the mobile site and not add content like you have.
Thanks for any help, this plugin really does work, I would love/need to exploit it to its full capability.
No way to have it working
Sorry to be the first to say I can't have it working, but hey... There must be one to say so at some point, ins't it ?
I have installed the plugin, activated it, created an iphone template, put the name of my template in the right place, activated the "iphone with user agent"... And nothing happens : the default template (desktop template) is displayed for iphone and fixed web browser. Just as if the user agent was not detected.
Running under joomla 1.5.14.
Do you have any clue why it is not working ?
Thanks in advance
Following my comment
I made some tracing of the code in mobilebot.php and it seems that the problem comes from the line 103 :
if ($this->params->get($mobileName, '0')) {
It should probably be :
if ($this->params->get($mobileName, '1')) {
Same thing for all other lines corresponding to parameters where "Yes" is "1" and "No" is "0".
What do you think ?
Thanks in advance for your reply
Best Regards
...
You need to make sure of two things:
1) Your template is correctly installed.
Go to the template manager (Joomla backend) and make sure it shows up in the list.
2) Make sure you're using the correct name for your template (the one that shows up in the template manager is the one you should use in the plugin configuration, be very exact with the name).
You can also test this with Firefox, there is a great extension out there that let's you "fake" your user-agent string so you can test Websites that depend on the user-agent (like in this case), it is called User Agent Switcher:
https://addons.mozilla.org/en-US/firefox/addon/59
Add the following user-agent:
Description: iPhone
User Agent: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)
App Name: AppleWebKit/420+ (KHTML, like Gecko)
App Version: Version/3.0
Platform: Mobile/1A543 Safari/419.3
If the plugin can't find your template it simply won't do anything (as it is happening to you), check, re-check
and make sure your mobile template is installed and configured correctly, I hope this helps! mobilebot.php
Thanks for your answer.
I must be missing something. Now it works. As if joomla has to "purge" some cache before serving the right template. Do you know of any internal cache that would have this behavior ? Of course I have tried emptying the cache through the admin UI.
Thanks for your advice concerning the user agent switcher for Mozilla. For that, I personnaly use Safari which allows to change the user agent easily through a menu.
Best Regards
Do not want to spam you, but..
I got it working by replacing line 235 :
$mainframe->setTemplate($this->selectedTemplate);
with :
$mainframe->setUserState('setTemplate',$this->selectedTemplate);
For any reason, it seems that the setTemplate function does not work properly (at least in Joomla 1.5.14).
Best Regards
Do not want to spam you, but..
I got it working by replacing line 235 :
$mainframe->setTemplate($this->selectedTemplate);
with :
$mainframe->setUserState('setTemplate',$this->selectedTemplate);
For any reason, it seems that the setTemplate function does not work properly (at least in Joomla 1.5.14).
Best Regards
I was wrong
Sorry but I was wrong. I had modified my Joomla core code and this was the reason for mobilebot not working.
You can remove my messages
Best Regards
Redirect to differnt site
Is there anyway to redirect to a different site or site directory instead of a sub-domain? It would be nice if the script didn't automatically detect and add the sub-domain when you want to redirect. Maybe you could have two options?
Janie
Google Adsense Mobile
Any help is greatly appreciated. :-)
Updated for home URLs
I have slightly modified the plugin so that it has a "home URL" for each template, in order to redirect to a different homepage depending on the user agent.
I can send it to you if you want (just give me an email or some URL to upload it);
Best Regards
...
Thanks!
Janie
...
Brat
Did you try the Mobile plugin at http://joomla.mobileplugin.net/ ?
They included a cache engine along with quite a few other options. It seems like a pretty robust plugin and it's not included at the Joomla.org extensions site. Unfortunately they don't have the redirect options that the nearsoft plugin does, which are the options I'm looking for.
I'm still hoping OP will share the homepage redirect version with me (everyone).
Janie
...
I tried the mobile plugin you mention on a site and it freaked out the googlebot somehow, kicking me out. Be warned. It seemed to get stuck in a loop not knowing what Google was, and my site dropped out of the rankings until I removed it. This seems to be much more friendly I must say, gonna try it nowm great work! ;-)
Apply modules to different templates
Nothing to download at mobile joomla
Maybe still on alpha state??
Home page
I have this line of code that puts the home page content on automatically, but when i remove this, other content can't be browsed..
if( !isset($GLOBALS['pdabot']['home']) || $this->params->get( 'componentonhome' ) )
echo '',"
";
Thanks
not working, no way
redirect...
I have one question. I would like mobile users to be directed to another page. (not a subdomain or the home page)
If the user agent is a mobile phone then direct them to say http://www.site.com/mobile.php
If the user agent is a desktop the standard index.php page is displayed.
Thanks.
Iphone Joomla Google analytics...
http://frenchan.blogspot.com/
problem
Redirection faild
redirect
I hope this helps.
Warren
...
$redirectURL='www.tinomobile.com/';
$directURL = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strcasecmp($directURL,$redirectURL) == 0)
{header( 'Location: http://www.tinomobile.com/news');};
...
Any idea why this is happening?
site redirection
I tried your code by adding it to the "PHP Fixes" under the default mobile template area. But it did not redirect. I set "Mobile with user-agent" and "Redirect to mobile subdomain" to "yes", and "Mobile with subdomain" to "no". I left all other options alone for now. Is there any else I need to consider?
Jpegs resizing
ES
What about Normal viewing?
I have a question though, Is there a way for users (or me!) to see my website normally (with no mobile plugin) through a link maybe?
I mean i use the plugin only for news cause i have an institutional site but what if i want to see the whole site?
Thanks in advance.
Url direct to articel
Great softwear! looking for this I think. Going to try it this week.
Just one question.
Does the template show up if I link straight to a articel page from a link in a webapp from the mobile (Iphone)
For exampel iphone.creativebyhands.com/index.php?option=com_content&view=article&id=7
and or if I use serch friendly URL:s on?
Best Regards Bo
Default Template
I have some issue with this plugin
I try to preview my site and I get error message: 404 component not found.
Problem is just with the home page (index.php), but every other page is ok.
Now here is the strange part: Problem appeared on my first computer with Windows 7 and IE 8 but on my second computer Win XP and IE8 it's OK, Firefox is ok on both of them.
So I try on my friends computer with IE and it's ok again.
I thought that something was wrong with my computer, and then I try to open it with my iPhone, and I get this same error again.
So it is not my computer error because it is server message and when I disable dis plugin website works fine.
I am using Joomlart JA Teline II on Joomla 1.5.15
PDA template no more on the linked url available
fantastic solution
Fantastic plugin - thanks so much for creating it.
I do have a question. For usability - is there a way for say an iphone to click on a "Go to Full site" button and then NOT get re-directed back to the iphone template?
I have seen that on a good many sites... possible?
thanks1!
redirect
I tried to put it in the Mobile subdomain name area, also i tried out the absölute URL thing you suggested above: $redirectURL='.... I copied and pasted into the "iPhone PHP Fixes" area with no modifications escept the URL. None of those worke. i end always with the iPhone on my default home page wich is not optimized for mobile devices. What do i do wrong? Thanks for your help and kind regards
how to install this plugin??
create subdomain, like iphone.xxx.com what is the location? Where can i find the template for each mobile?
more explications is very greatful!
(excuse me for my english, but i speak frenc (from belgium))
Problems detecting IE8 on Vista
Has anyone had problems with this plugin and IE8 on Vista. It seems as though when accessing our site with IE8 on Vista it is loading the "Default Mobile Template (All Mobile Devices / Catch-All)" instead of going onto the regular web template.
Thanks for any and all help!
Jon
Same issue as above
I am having the same issue as the previous poster. When accessing sites with the mobilebot plugin from Vista IE8, then it defaults to the mobile template. Is there any way that we can get WURFL mobile verification as opposed to relying on a manual text list?
Thanks,
Charels
is threr a mobile extension for joomla 1.0
thanks
brilliant plugin
Just a thought, but maybe one way to do the link to the full site template would be to use another subdomain like full.mydomain.com which would force it back to the full template?
I can't use subdomains on my site because a component uses the full domain to check the encrypted license file.
Narrowed down the IE8 Detection thing
Some answers
Yes Janie, that could be a really useful feature, I'll keep that in mind for the next release
First option is to do it with PHP in the "PHP Fixes" field of the plugin parameters for the mobile device, something like what is described in the comment by warren , December 15, 2009
You could also make an .htaccess redirection when the domain is something like iphone.example.com to the other site
Other option is to acommplish what you want with DNS, for example, you could have a Name-based Virtual Host in Apache that handles the requests to iphone.example.com pointing to the directory you want
* To Shawntay , October 14, 2009 (AdSense)
The easiest way I can think of right now:
You could define a mobile-only module position in your mobile template (not present at all in any other Joomla! template of your site), then create a module with a raw PHP/HTML plugin such as mod_custom or mod_php and include your AdSense JavaScript code in it and assign this new module to that position
Maybe you're already doing this, if this is not working first make sure the mobile device you're testing this on supports JavaScript/Flash (this depends on the type of Ads you're trying to display)
* To Spanners , October 22, 2009 (Different templates, different modules)
You have a good point there, what you need to do is to have module positions named differently in your default and mobile templates like:
left
left_mobile
In your default template you only use "left" and in the mobile template you use "left_mobile" to assign completely independent modules to them, (Note: you may need to switch temporarily between templates in the Joomla! backend when assigning modules)
* To warren , November 30, 2009 (Redirect to another Joomla! page)
Good feature request, we will keep it in mind
Some answers
The resizing of JPEG's you're mentioning is most likely related to the device or the mobile template you're using, I'll recommend you taking a look at the source code of such template to find out what is going on
* To Fernmac , January 25, 2010 (Link to main site)
* To Sandra Aguilar , February 04, 2010
* To Rod , February 15, 2010
That could be a good feature, I'll give it some thinking, thank you for the suggestion!
* To Bo , January 26, 2010 (friendly URLs)
This depends on the specific configuration of your Joomla! Website, but in general this should work
* To dejansoftware , February 13, 2010 (Problem Vista/IE
I haven't heard of this problem, did you find a solution?
(could this be related to the problem described two answers below?)
* To Val , February 25, 2010 (Howto, subdomains?)
* To Sandzak , March 05, 2010
Subdomain based detection is not necessary, that is for more advanced configurations, you only need to define a template for your particular mobile device in the plugin parameters and that should do it!
* To Jon Lackey @zuno , March 12, 2010 (Vista/IE8 Problem)
* To Charles , March 19, 2010
* To Brian Richards , March 26, 2010
What Brian Richards found sounds like the solution to me, this is the reason behind leaving the parameters configurable by the user (new user agents strings in the future, etc), removing the keyword "nec" from the default and saving the changes should fix the problem
* To yan , March 25, 2010 (Joomla! 1.0 version)
Sorry yan, there's no version for Joomla! 1.0, I recommend you though if you can to migrate your site to Joomla! 1.5+ because the version you have has been deprecated some time ago
Update mobile list and switch off
is there an updated user agent list? It seems don't work with Opera Mobile, for example.
is there a way for users to switch to the default template/s?
I want to use a single simple template for all mobile devices but to give the option to swith to the "complete" site version.
Thanks
http://www.moncleroutletstore.eu
Switch to Full Site
?template=name_of_template
It will show the website using that template.
Switch to Full Site - not working
Full site
Found a work around for Full Site
I've found a quick work around:
at the end of the url for the link back to your full site add ?fullsite=yes
Then in mobilebot.php add this code to the doDetectionLogic function:
$no_mobile = $_GET["fullsite"];
if ($no_mobile == 'yes' || isset($_COOKIE["mobile"]))
{
$GLOBALS['is_mobile'] = false;
$GLOBALS['is_mobile_'] = false;
$GLOBALS['is_mobile_det_ua'] = false;
$expire = time() + 60*60*24;
setcookie("mobile", "FullSite", $expire);
}
When the user clicks on the link the first time it will check for the full site value in the url, then once it matches it sets a cookie that you can change the expiry time of, this then allows the user to view the full site and click on links without being redirected to the mobile site for however long you choose.
Webmaster
this plugin was just removed from Joomla Extensions. It's really too bad, because all the other options out there don't offer the freedom that this one did or they just don't work.
Any plans on updating for Joomla 2.5?
I've been giving it a go, replacing global $mainframe
with $mainframe =& JFactory::getApplication();
But i'm stuck at why I get this error:
Warning: require_once(/home/XXXX/administrator/components/com_templates/helpers/template.php) [function.require-once]: failed to open stream: No such file or directory ...
Anyways, I'll be hammering away at it.
If I manage to get it working in 2.5 I'll let you know...
(but I might just find another extension and move on, as I haven't too much time to spend on it.)
Peace.



