Welcome, Guest
Username Password: Remember me

[SOLVED] identify if page being viewed in a mobile device
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: [SOLVED] identify if page being viewed in a mobile device

[SOLVED] identify if page being viewed in a mobile device 13 years, 8 months ago #3867

  • Boris99
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Karma: 0
Hi,

I have various photos etc that are included in website pages using php 'include' code (using sourcerer), and these aren't showing very well on mobiles. The code is in the articles themselves, not in modules.

If I want this code to be different for mobile devices, is there a (php?) variable or other way of picking up whether the article is being viewed in a mobile so I can use this in my include file?

(An example can be seen at page www.italythisway.com/places/lake-garda.php where on a ipod the top picture and hotel box and google ads is too wide for the screen - I want to remove the hotel search and the google ads on mobile devices)

Cheers!
Last Edit: 13 years, 7 months ago by Boris99. Reason: now solved

Re: identify if page being viewed in a mobile device 13 years, 7 months ago #3868

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
Just test _MJ constant:
if(defined('_MJ')) {
// mobile
} else {
//desktop
}
Last Edit: 13 years, 7 months ago by dryabov.

Re: identify if page being viewed in a mobile device 13 years, 7 months ago #3869

  • Boris99
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Karma: 0
Exactly what I needed
Thanks very much

Re: identify if page being viewed in a mobile device 12 years, 4 months ago #10374

  • bnighter
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Karma: 0
Is this .php code?
I am using this defined('_MJ') in frontpage.php and it does not appear to detect in my kindle. I am looking for some php code to call to determine if the user is a mobile device.

Re: identify if page being viewed in a mobile device 12 years, 4 months ago #10380

This is, by far, the easiest method to handle cell phone users. Instead of worrying whether they can or cannot see your pages, simply put a link somewhere near the top of the page that points to your mobile version. Then the readers can self-select whether they want to see the optimized version or continue with the normal version .
Increase Website Hits
Last Edit: 12 years, 4 months ago by brewtondaniel2.
  • Page:
  • 1
Time to create page: 0.12 seconds

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.