|
|
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 (49)
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
User Agent Testing
Janie
Please take a look at MobileJoomla!
Just released a new way of mobilizing web sites: Mobile Joomla! Please take a look and let us know how it looks on iPhone!
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



















