The Mobile Content Switch Plugin is a free Joomla Plugin that will enable you to hide or show content depending if the user is visiting your site from an iPad, iPhone, iPod Touch, or not.
Great to display an embedded Flash video for non-Apple mobile devices, and a QuickTime movie for Apple mobile devices, or other such uses.
(Thanks to Peter van Westen from www.nonumber.nl for the help with regex)
Usage:
{ipad}Display content to visitors ON an iPad.{/ipad}{noipad}Display content to visitors NOT on an iPad{/noipad}{iphone}Display content to visitors ON an iPhone or iPod touch.{/iphone}{noiphone}Display content to visitors NOT on an iPhone or iPod touch.{/noiphone}{applemobile}Display content to visitors in EITHER an iPad, an iPod, or an iPhone{/applemobile}{noapplemobile}Display content to visitors in NEITHER an iPad, an iPod, or an iPhone{/noapplemobile}{android}Display content to visitors on an Android device{/android}{blackberry}Display content to visitors on an BlackBerry{/blackberry}{palm}Display content to visitors on an PalmOS device{/palm}{sonyericsson}Display content to visitors on an SonyEricsson (Nokia) device{/sonyericsson}{symbian}Display content to visitors on an SymbianOS device{/symbian}
Important Notes: (updated June 6, 2010)
- Set in Global Configuration > Systems > Cache = no for the plugin to work, otherwise what you will see is the cached version of the article, which may have been generated by a device other than the one you are viewing the article on.
- If you have caching enabled, and your content is in a module, make sure to set the module not to be cached (advanced parameters > caching)
- If you use the plugin in a module, make sure that the module is capable of running plugins (such as mod_placehere)
Changelog
Version 2.1 – August 11, 2011
- Support for Joomla 1.6 (Thanks to Louis Carlos)
- Added {mobile}{/mobile} {nomobile}{/nomobile} parameters (Thanks to @Mano)
Version 1.7 – January 29, 2011
- Added support for Android, Palm, Blackbery, Symbian, Palm, and Sony Ericsson
Version 1.6 – June 16, 2010
- Resolved an issue with iPhone compatibility
- To upgrade, unzip the plugin and copy the mobilecontentswitch.php and mobilecontentswitch.xml files to /plugins/content
Download the Mobile Content Switch Plugin for Joomla 1.5
Download the Mobile Content Switch Plugin for Joomla 1.6
Found the plugin useful?
All proceeds will be donated to Words of Peace Global

Cool, thanks!
Great idea. I just ran a test and noapplemobile works, as does iphone specivid.
But when I try to use applemobile as a catchall for iphone and ipad it goes wrong and shows the noapplemobile content.
I am only testing on iphone as I don’t have an ipad.
Great idea, what would be ideal (for me anyway) would be a way with the plugin to hide module positions. If I didn’t want the right or left menu areas to display, I could just select them in the plugin. It would pull all of the module positions from the template itself since many of the newer templates add new positions.
You can do this by tweaking your template’s index.php.
For example:
countModules(‘mymodule’) && strstr($_SERVER['HTTP_USER_AGENT'],’iPad’);) : ?>
Hi Jossi
Can you give us more examples on how to tweak the index.php — such as for both ipod and ipad. Or would iPad handle all possibilities
Thanks,
Rowby
For example, could you give us a complete rewrite of the following example that I have in my template to handle the iPad and Ipod
countModules(‘banner’)) : ?>
Thanks!
Hmmmmm the comment system stripped out most of my code example.
Perhaps you can add very specific examples in your useage section of this page tos howhow to handle modules.
Thanks!
Just the same as Don, works great with iphone tag but not with applemobile…
Could it be fixed ?
Hi, just the same as Don, works perfect with the iphone tag but not with the applemobile one ?
SHould I use {ipad}{iphone}{/iphone]{/ipad} ?
Having the same issues as Don.
I have an iPhone and an iPad…
using {applemobile} doesn’t show the content on an iphone…
any help would be appreciated
Hi, the plugin is very helpful but it seems doesn’t work perfectly.
By using the code
{applemobile}testapple{/applemobile}
{noapplemobile}testnoapple{/noapplemobile}
the results are:
on laptop “testnoapple” (correct!)
on iPhone “testnoapple” (incorrect!)
I need your help to solve the problem…
Thank you very much in advance.
Andrea
@Andrea, Rod and Jerome
Please note that you have to set in Global Configuration > Systems > Cache = no
for the plugin to work, otherwise what you will see is the cached version of the article, which may have been generated by a device other than the one you are viewing the article on.
If you have the content on a module,, make sure that the module is capable of running plugins (such as mod_placehere)
If you have caching enabled, and your content is in a module, make sure to set the module not to be cached (advanced parameters > caching)
Dear Jossi, thank you very much for your answer.
I have just checked the system configuration, and the cache is already set on “no”.
In my case I would like to use the plugin directly in an article: here’s the test code:
{applemobile}applemobile{/applemobile}
{noapplemobile}noapplemobile{/noapplemobile}
and you can test by yourself here:
http://www.milestonesrl.tv/index.php?option=com_content&view=article&id=97&Itemid=233
If I open the page by PC, it works fine (noapplemobile label appears).
If I open the page by iPhone, there is an error (noapplemobile label appears too).
If I open the page by iPad, it works fine (applemobile label appears).
So the problem seems to be with iPhone only.
This plugin is very important for me and I need your support: I’m ready to donate a good amount if you can help me. My e-mail is webmaster@milestonesrl.com
Thank you in advance.
Andrea
Hi Andrea, I am making some adjustments and will upload a new version today.
Thank you for your feedback!
New version 1.6 available, resolving the iPhone compatibility issue reported.
Enjoy!
Hi, great plugin!
Quick question, I have an older Joomla 1.0 site…do you know if I can use the plugin on 1.0?
Thanks!
@ Chris w
You can certainly give it a try.
How can I install it on Joomla 1.0?
Your help will highly be appreciated.
hi, im new to all this can you please tell me how to instal and run it on my video website.
thank you
@Hasan
This plugin was designed for Joomla 1.5.
@Jorge
To learn about installing plugins, see the WIki http://docs.joomla.org/How_do_you_install_an_extension%3F
Problem: I cannot get the link to work to download the product.
Thank you.
This is now corrected. Enjoy.
This looks great but not being a coder I have a dumb question, sorry – where do you put the code to make this work? Does it go in the Header of the mobile and non mobile templates?
Is there a tutorial?
Is there an example page where I can use Firebug to see the code?
Thanks
@Jonathan
You put the code anywhere in any of your articles.
For example:
Hello,Welcome to our Website
{ipad}I see that you are using an iPad.{/ipad}
{iphone}I see you are using and iPhone or an iPod touch.{/iphone}
{applemobile}We have specific material suited for your mobile devices, so enjoy!{/applemobile}
That content will not show for visitors that come to your site using a desktop browser (or any other browser that is not an iPhone or Ipad)
Jossi
Brilliant thank you, works perfectly.
Happy New Year
I’m having issues executing the video code within our tags. Is there a standard for embedding video within your tags? Is there a particular editor that work / does not work with your plugin?
Here is my code:
{noapplemobile} {/noapplemobile}
any suggestions i’d appreciate.
-jake
@Jake:
If you have problems with your editor removing the tags, simply set your editor to “No Editor”.
I would love to use this, can you extend it to deal with Android and Blackberry as well, and not just Apple devices?
Thanks!
I am sending you via email a version that you can test.
{android}Display content to visitors on an Android device{/android}{blackberry}Display content to visitors on an BlackBerry{/blackberry}
{palm}Display content to visitors on an PalmOS device{/palm}
{sonyericsson}Display content to visitors on an SonyEricsson (Nokia) device{/sonyericsson}
{symbian}Display content to visitors on an SymbianOS device{/symbian}
@jake: Just place the embed code within the tags. If it is not working for you, give me some more details on the problem.
Does this provide the ability to display a .jpg instead of a .swf for mobile devices?
@will
yes, of course. Just wrap the embed tag for flash or the img tag with
Hi,
Cant seem to get this working in a “Custom Html” module… I have it working on Article pages fine. When i try to insert the Tags into a module they dissplay as text on the forntend of the site. Im using 1.5.. any ideas?
hi jossi,
i already installed the plug-in and put the code in article but it’s still not running.
Can you add {noandroid} tag in this GREAT plugin ? It is much appreciated ..
Thanks
@Niall: Modules have to be able to execute plugins for this to work. For example, the custom HTML module has a parameter “execute plugins”.
Check that the plugin you are using has that capability, otherwise it will not work.
@Chris.
Yeas, I will do that… Please email me at jossif{at}emandtee.com so that I can send you the plugin to test
@anne: Make sure to enable the plugin in Extensions > Plugin Manager
Hi Jossi,
Very nice plugin, works wonderfully, and so easy to use !
Do you still plan to add a {noandroid} tag, as you told Chris ? This would be useful. I can test it on my android device if needed.
Thanks
Great idea, easy to use plugin. Thank you.
I have needed a little suplement, maybe you find it useful.
I have added mobile and nomobile tag into the mobilecontentswitch.php.
$mobile = $ipad || $iphone || $android || $blackberry || $symbian || $palm || $sonyericsson;
if ($mobile) {
//{mobile} tags regex
$row->text = preg_replace( “#\{nomobile\}(.*?)\{/nomobile\}#s”, ”, $row->text ); // removes {nomobile} tags + content for nomobile content
$row->text = preg_replace( “#\{mobile\}(.*?)\{/mobile\}#s”, ‘\1′, $row->text ); // removes just the {mobile} tags from content
} elseif (!$mobile) {
//{mobile} tags regex
$row->text = preg_replace( “#\{mobile\}(.*?)\{/mobile\}#s”, ”, $row->text ); // removes {mobile} tags + content for ipad content
$row->text = preg_replace( “#\{nomobile\}(.*?)\{/nomobile\}#s”, ‘\1′, $row->text ); // removes just the {nomobile} tags from content
}
@ webmano.hu
Thank you. I shall add this to next release. Glad you found it useful.
@Marge, Will have this ready later today for you to test
Great!!! Thanks for the news,I need this plugin to develop my new website!!!thanks mate!cheers
Will this work with Joomla 1.6.4?
I have not tested it on 1.6
Hi @Jossi.
I changed some lines to make it work for Joomla 1.6 and also added the {mobile}{/mobile} {nomobile}{/nomobile} code by @Mano.
I don’t know how to upload it to Joomla extensions directory but I’d like you to update yours instead, which would be better.
Want me to send you the zip file in an email?
Regards,
Ciul
Thanks, Ciul.
You can email me at jossif [at] emandtee.com with the new version. Please also provide info on contributors, so that I can add credits.
I’m desperate looking for such a plugin for Joomla 1.7.0.
Is it compatible ?
Jossi
Fantastic plugin for Joomla 1.5, I won’t upgrade to 1.7 until there’s a version of your mobile content switch!
Regards
Jonathan
I cant see the changes for mobile/nomobile in the version (2.0) I downloaded. Is that correct or am I missing something?
I will be uploading a new version compatible with Joomla 1.6 and 1.7 in a day or two
New version uploaded. Thank you Luis Carlos!
New version uploaded!
Yes, it is now.
It is not working for my iPad. It hangs a Flash movie up on the preloader. I’m using it inside a Custom HTML module.
@Paul: what tags did you use?
Also, please read note:
Set in Global Configuration > Systems > Cache = no for the plugin to work, otherwise what you will see is the cached version of the article, which may have been generated by a device other than the one you are viewing the article on.
If you have caching enabled, and your content is in a module, make sure to set the module not to be cached (advanced parameters > caching)
If you use the plugin in a module, make sure that the module is capable of running plugins (such as mod_placehere)
Hi Jossi,
I have just installed the plugin. Set the cache system to no. Edit a new content article with:
a video code with flash and the tag noapplemobile
a video mp4 with the tag applemobile
The plugin is active.
From a PC I can see only the video with flash which is correct. From a ipad 1 and a iPhone3 I can only see the logo Adobe Flash.
I tried with the tag iPad : same thing.
No cache, no module, plugin active, tag at the beginning and at the end with a /, Joomla 1.53, new article (no cache problem) but still not working.
What is your diagnosis ?
Are you using the version for Joomla 1.5 or 1.6?
Can you try on a test page the following?
{applemobile}I am viewing this in an Apple iOS device{/applemobile}
{ipad}I am viewing this in an iPad{/ipad}
{iphone}I am viewing this in an iPhone{/ipad}
{noapplemobile}I am viewing this in an device that is not an Apple iOS device{/noapplemobile}
I took my time to make the tests : it is working fine when the cache is off.
And i can set it on after a time (15mn).
I am trying to install the Mobile Content Switch Plugin but the error “Error! Could not find an XML setup file in the package.” appear. What is the problem? Please help.
I am using Joomla 1.5.7
Thank you in advance.
@Sam – Maybe something wrong with the zip file? I suggest you unzip the package and zip again, Then try to install it again.
Great plugin !
But is there a way to transform it into a system plugin instead of a content plugin ?
Because as it’s a content plugin it isn’t executed in rss feeds for example or in components, so if you use joomlatags for example you’ll see {noapplemobile}{/noapplemobile}{applemobile}{/applemobile} :
http://www.360images.fr/chateau.html
thanx !
Excellent plugin!!!
But I would like it to have a {noblackberry} option, as my site is on Joomla 1.5.23 and I can’t use {nomobile}
Thanks.
@Liber:
Open mobilecontentswitch.php and replace lines 65 to 73 with this:
if ($blackberry) {$row->text = preg_replace( "#\{blackberry\}(.*?)\{/blackberry\}#s", '\1', $row->text ); // removes just the {blackberry} tags from content for blackberry devices
$row->text = preg_replace( "#\{noblackberry\}(.*?)\{/noblackberry\}#s", '', $row->text ); // removes {noblackberry} tags + content for no blackberry content
} elseif (!$blackberry) {
$row->text = preg_replace( "#\{blackberry\}(.*?)\{/blackberry\}#s", '', $row->text ); // removes {blackberry} tags + content for non blackberry devices
$row->text = preg_replace( "#\{noblackberry\}(.*?)\{/noblackberry\}#s", '\1', $row->text ); // removes just the {noblackberry} tags from content
}
This plugin is fantastic. It should be in the core of joomla since it serves up a very needed feature: a way to show different content specifically made for mobile devices while the desktop content remains untouched. Thank you for writing this I hope you’ll continue to update it for future versions of joomla its really needed
We have used this in our Joomla Real Estate Websites and it works Great ! Thanks for the post and sharing and spreading the power of Joomla.
Custom IDX Solutions
This plugin is so simple but awesome! Just works out of the box and solves many troubles! Great! Thank you for your work!
I really enjoy your plugin! I’m having a little trouble making it work in HWDRevenueShare. I’m trying to hide banners on the video pages, but it’s still loading them. It’s showing the {noiphone}{/noiphone} tag around the banner.
Thoughts?
Do you have caching enabled? Read the caveats on the plugin description above…
I do not have cache enabled. I’m sure it’s because the component isn’t accepting the plugin tags.
I even tried editing the template files to not load that module position with the tags, but with no change.
BTW – is there any way that I can get a notification when a response is posted here?
Thanks!
If you are using the plugin in a module, make sure that the module is capable to execute plugins.
Hi Jose
Will the 1.6 version work on 2.5?
Thanks
Mobile content switch not working in mobile joomla? I’m trying to use the plugin on my mobile joomla site but it just outputs the tags instead of processing them. It shows the tags on the frontend like this:
{nomobile}
my content
{/nomobile}
{mobile}
mobile content here
{/mobile}
Any ideas on why this wouldn’t be working in the mobile joomla component?
By the way Im using it on joomla 1.7 and its happening on the desktop side too I didn’t notice that before.
one other thing i forgot to mention sorry im trying to use the plugin inside of a redshop category template.