How do you add redirect script for mobile sites in Joomla?

15 replies
Hello warriors,

I'm wondering if any of you knows this...

When you make a mobile version for a site in Wordpress there is a plugin that you need to install to make the redirect.

When you have a site in html there is a script that you add to the main site for the redirect.

But how is this working in joomla? I don't have experience with it. Can anyone elighten me please?

Thank You!

Regards, Marian
#add #joomla #mobile #redirect #script #sites
  • Profile picture of the author Jay Moreno
    What version of Joomla are you using - actually the principle would be the same you can add it to your Joomla template - or perhaps easier would be to add the code to a custom module and have it published on all your pages. You would have to turn off your html editor to add the script though to your custom module.

    There are number of plugins that you can install that will do the detection for you too - check this link out... Search - Joomla! Extensions Directory

    if you need step by step instructions just let me know

    cheers

    jay
    Signature
    Sorry, I am too busy helping people to think of a cool signature!
    {{ DiscussionBoard.errors[4378075].message }}
  • Profile picture of the author Jay Moreno
    yeah i usually like to upgrade the default to one called JCE - thats if your editing the look of your articles thats pages/posts for WP users

    however when you add snippets of code it will keep erasing it unless you turn off the html editor (a security feature i guess!) with JCE it lets you toggle between the two modes easily.

    you can add a custom module which i guess is similar to a widget in WP that will also let you add the snippet of code but again you will need to turn off your editor...

    you can always use a custom content module by joomlaworks.gr Custom Code (module) | JoomlaWorks

    i have used it several times and it serves its purpose well

    there are many different ways to add code with other various plugins - but if your not too unfamiliar with html and thats the only thing you are doing the easiest would be probably to just edit the template

    just log in the back end go to extensions -> template manager

    select the template you want to edit - typically its the default one

    click edit html and you will see the source code for the template... personally i think its simpler to edit than having multiple files like WP but thats a matter of opinion

    you should also look at upgrading your joomla installation too as the latest version of 1.5 is 1.5.23
    Signature
    Sorry, I am too busy helping people to think of a cool signature!
    {{ DiscussionBoard.errors[4378736].message }}
    • Profile picture of the author ihelfman
      Jay,
      Where do you put the redirect script in the Joomla 1.5 template? I put it above the bottom <head>, like I do in WP. Didn't work in Joomla.

      Advance thanks for your help,
      Ivan
      {{ DiscussionBoard.errors[5984932].message }}
  • Profile picture of the author Jay Moreno
    hi ivan - which redirect script are you using?
    Signature
    Sorry, I am too busy helping people to think of a cool signature!
    {{ DiscussionBoard.errors[5984989].message }}
    • Profile picture of the author ihelfman
      Originally Posted by Jay Moreno View Post

      hi ivan - which redirect script are you using?
      One that came with My Mobile Website Builder, a WP plugin. I've attached it below, with the mobile URL near the end of the script. The script works with WP scripts.

      Also, my client and I would like to convert his site, Michigan Elder Law Attorneys, to WP. It's a content-heavy law firm site. Do you do that? Or could you suggest a plugin or an affordable Joomla whiz that does that? I read about Joomla 2 WordPress, a 2008 plugin that worked on WP V. 2.7.

      Advance thanks,
      Ivan




      <script type='text/javascript'>(function(a,b){if(/android|avantgo|blackberry|blazer|compal|elaine|fe nnec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link )|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar (ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|b umb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a |jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|d o|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran |owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(4 0|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98 )|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))window.location=b})(navigato r.userAgent||navigator.vendor||window.opera,'http://www.internetmarketingmi.com/mobile');</script>
      {{ DiscussionBoard.errors[5985103].message }}
      • Profile picture of the author iAmNameLess
        Originally Posted by ihelfman View Post


        <script type='text/javascript'>(function(a,b){if(/android|avantgo|blackberry|blazer|compal|elaine|fe nnec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|symbian|treo|up.(browser|link) |vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar (ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|b umb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a |jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|e-|e/|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|d o|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran |owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40 |5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98 )|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(-|2|g)|yas-|your|zeto|zte-/i.test(a.substr(0,4)))window.location=b})(navigato r.userAgent||navigator.vendor||window.opera,'http://www.internetmarketingmi.com/mobile');</script>
        That actually should work.. did you add it to your index.php file or the template's index.php?
        {{ DiscussionBoard.errors[5985150].message }}
        • Profile picture of the author ihelfman
          I added it to the template's index.php, above the bottom <head>, as instructed by the my WP mobile website creator plugin's vendor.

          Thanks for your help. I'll let you know if it works for me. I'm using Joomla v. 1.5. Never used Joomla before, so the template editor is foreign to me.
          {{ DiscussionBoard.errors[5985244].message }}
          • Profile picture of the author iAmNameLess
            Originally Posted by ihelfman View Post

            I added it to the template's index.php, above the bottom <head>, as instructed by the my WP mobile website creator plugin's vendor.

            Thanks for your help. I'll let you know if it works for me. I'm using Joomla v. 1.5. Never used Joomla before, so the template editor is foreign to me.
            Well, creating a mobile site in wordpress and then moving it to work with joomla may not always come without hassle.

            Which version of 1.5? It goes up to 1.5.25 now but current version is 2.5.

            Have you tried going to template manager, clicking on your default template, and click edit HTML? That might be the easiest way for you.
            {{ DiscussionBoard.errors[5985276].message }}
            • Profile picture of the author ihelfman
              Version 1.5.14. I am working with the template manager.
              The law firm's webmaster installed Joomla in 2009. Facing Joomla for the first time, I don't want to upgrade it or risk doing anything that could crash or destroy the firm's site. Liability I don't need. Thought I could just stick in my redirect code, but I was wrong. Will try again tomorrow.
              {{ DiscussionBoard.errors[5985329].message }}
              • Profile picture of the author iAmNameLess
                Originally Posted by ihelfman View Post

                Version 1.5.14. I am working with the template manager.
                The law firm's webmaster installed Joomla in 2009. Facing Joomla for the first time, I don't want to upgrade it or risk doing anything that could crash or destroy the firm's site. Liability I don't need. Thought I could just stick in my redirect code, but I was wrong. Will try again tomorrow.
                Get Jupdate... you can upgrade easy without worrying about messing anything up. Akeeba back up is another good extension, in case you want to experiment, you can back up a clone of the website.

                Problem you have right now is that I could exploit your website right now in under 2 minutes just because of all the patches you're missing.
                {{ DiscussionBoard.errors[5985419].message }}
                • Profile picture of the author ihelfman
                  Originally Posted by iAmNameLess View Post

                  Problem you have right now is that I could exploit your website right now in under 2 minutes just because of all the patches you're missing.
                  Scary.

                  Thanks for the tip.
                  {{ DiscussionBoard.errors[5986587].message }}
                  • Profile picture of the author msimko
                    On Joomla 1.5, you can try using something meant for another purpose.

                    One of the plugins for google analytics has you paste in the entire script from google, and it places it in the head section of pages. I believe it is WebGuru's Google Analytics. You can find it at extensions.joomla.org It allows you to put the whole script in. You'll do that from the plugin manager after you install the plugin from the extension manager.

                    Alternately, you can go to the templates in the extension manager and paste the code directly into your template by editing the html in the template manager.

                    I'd go the plugin method. That way you can change templates if you want.

                    I've used this (co-opted that plugin) to put a different script into a Joomla 1.5 web site. The Google plus script.

                    Joomla is great. I've been using it for years. We've got a user group her in NY, and we have another JoomlaDay coming up in September.
                    {{ DiscussionBoard.errors[6354109].message }}
                  • Profile picture of the author msimko
                    I just found easyheader in the joomla extension directory (jed). Use that.
                    {{ DiscussionBoard.errors[6354297].message }}
  • Profile picture of the author iAmNameLess
    Originally Posted by ihelfman View Post

    Jay,
    Where do you put the redirect script in the Joomla 1.5 template? I put it above the bottom <head>, like I do in WP. Didn't work in Joomla.

    Advance thanks for your help,
    Ivan
    take out the *'s define***('MOBILE_SITE_URL', 'http://mobile.yoursite.com');
    if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE ||
    strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== FALSE) {

    header("Location: " . MOBILE_SITE_URL);****
    }

    Add that and it should work.. index.php file in your root joomla

    You will need to add the other user agents for other devices.

    Converting from joomla to wordpress seems like a waste. Why go with something more limiting? Usually people will want to migrate from wordpress to joomla, and eventually joomla to drupal.
    {{ DiscussionBoard.errors[5985126].message }}

Trending Topics