screen-shot-2010-04-08-at-70411-pm

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}

joomla_commpow_sm

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

92 thoughts on “Mobile Content Switch Plugin for Joomla

  1. 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.

  2. 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.

  3. You can do this by tweaking your template’s index.php.

    For example:

    countModules(‘mymodule’) && strstr($_SERVER['HTTP_USER_AGENT'],’iPad’);) : ?>

  4. 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

  5. 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!

  6. 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!

  7. 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} ?

  8. 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

  9. 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

  10. @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)

  11. 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

  12. Hi Andrea, I am making some adjustments and will upload a new version today.

    Thank you for your feedback!

  13. New version 1.6 available, resolving the iPhone compatibility issue reported.
    Enjoy!

  14. 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!

  15. 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

  16. @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)

  17. 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

  18. @Jake:
    If you have problems with your editor removing the tags, simply set your editor to “No Editor”.

  19. 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}

  20. @jake: Just place the embed code within the tags. If it is not working for you, give me some more details on the problem.

  21. 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?

  22. hi jossi,

    i already installed the plug-in and put the code in article but it’s still not running.

  23. @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.

  24. @Chris.
    Yeas, I will do that… Please email me at jossif{at}emandtee.com so that I can send you the plugin to test

  25. 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

  26. 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
    }

  27. 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

  28. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>