#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    5

    Device detection help


    I have found detectmobilebrowsers.mobi after having read part of my Mobile Web Design for Dummies book and have generated the function below which I hope (if I'm going about it the right way)

    Code:
    require_once('mobile_device_detect.php');
    
    mobile_device_detect(true,false,true,'[some URL]',true,true,true,false,false);
    So far I have to very basic html pages with just some plain text in them with my intended desktop version and mobile version in a different folder (I am using the Nokia 2730 for the time being which uses the OperaMini Browser). I have 2 questions:

    1) should my pages have the .html or .php extensions?
    2) where should those 2 lines go exactly in the code for it to detect my nokia device and re-direct appropriately?

    I tried it using the .html extension and my phone displayed the desktop version when I was hoping it would display the mobile version.

    When using the .html extension I have found that the PHP function which I had put in the 'head' section of the page was actually being displayed as text at the top of the page when viewing on a desktop computer (the phone just displayed the normal desktop text).

    When I changed the desktop version to .php it failed to work on both my phone and a desktop computer.

    I appreciate this may be a 'noob problem' but right now I most certainly am a noob when it comes to Mobile Web Design
    Last edited by willy155; February 3rd, 2011 at 09:07 AM. Reason: More details discovered
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    5
    Have discovered why it wasn't working...I read the 'see support' section of that website and it informed me through the "How do I make this work on my HTML pages?" FAQ with the answer:

    Problem
    HTML is code the end user's browser will process and PHP is something that the webserver will process, including PHP in HTML pages isn't going to work and will just show the function in the page unless the server is instructed otherwise.

    Solution

    Assuming you're hosting in an Linux environment you can add the following to your .htaccess file which will instruct the server to execute PHP inside HTML and HTM pages.

    AddType application/x-httpd-php .html
    AddType application/x-httpd-php .htm
    AddHandler x-httpd-php .html .htm .cgi .php

    Your webhost will need support for PHP and .htaccess - please contact your host direct to address these issues.

IMN logo majestic logo threadwatch logo seochat tools logo