ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Advice for Serving Template Group as Mobile Site with Subdomain?

December 18, 2012 9:32pm

Subscribe [3]
  • #1 / Dec 18, 2012 9:32pm

    msmith29063

    75 posts

    I’ve done some reading on various possible ways to do this. I’ve currently developed a mobile version of an EE2 site in a template group:

    http://www.mysite.com/mobile

    I’d like to make it accessible at:

    mobile.mysite.com

    Does anyone have any recommendations for the best way to do this? Note that there are a few templates within this group that will be used and I will be passing some IDs through the URL as well, like:

    mobile.mysite.com/staff/view/1234

    I ran across this article:

    https://supergeekery.com/geekblog/comments/how_to_make_a_mobile_version_of_your_site_with_expression_engine_2

    Is it necessary to do this? Or can it be done with mod rewrites with .htaccess?

    Thank you for any help you can provide.

  • #2 / Dec 19, 2012 6:36am

    Edd Smith

    19 posts

    The way i approach mobile site in EE is…
    1) Create the mobile template
    2) Detect the mobile device
    3) Forward it to the mobile template

    You could use .htaccess to forward the subdomain mobile.mysite.com to the template.

    See it in action here…
    http://www.purpleclaw.co.uk/

  • #3 / Dec 19, 2012 9:29am

    msmith29063

    75 posts

    What are you using to detect the device? Any recommendations?

    And you would just redirect with .htaccess to the template URL from the subdomain? So when users type in the subdomain—they just get redirected to http://www.mysite.com/mobile? I was looking to keep users at the subdomain if possible. Is that possible?

  • #4 / Dec 19, 2012 10:51am

    Edd Smith

    19 posts

    In theory it should be possible, i believe there are instructions in the link you posted. I was always a bit nervous about using the subdomain as I was nervous about doing so interfering with the way expression engine and its plugins behaves. So just went with what I deemed to be the safer option.

    I have tried a few methods for detecting mobile, this is my favourite thus far. Just stick it in the top of the head.

    [removed]
    
    var isMobile = navigator.userAgent.match(/iPhone|iPod|Android|BlackBerry|Opera Mini|IEMobile/) != null;
    
    if (isMobile != false) {
         [removed] = "http://www.webaddresshere.co.uk"
    }
    
    // add "iPad" to the above to lump iPads in with the mobile redirect
     
    [removed]

  • #5 / Dec 19, 2012 12:24pm

    Gareth Davies

    491 posts

    There is a nifty little plugin as well should you wish:

    http://devot-ee.com/add-ons/mx-mobile-device-detect

  • #6 / Dec 19, 2012 12:31pm

    Edd Smith

    19 posts

    There is a nifty little plugin as well should you wish:

    http://devot-ee.com/add-ons/mx-mobile-device-detect

    I tried that one. It misbehaved at times though and has limitations, found using the above JavaScript manually was the most reliable way whilst retaining full expression engine functionality.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases