Welcome, Guest
Username Password: Remember me

How to detect in php that a script is answering for a mobile?
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: How to detect in php that a script is answering for a mobile?

How to detect in php that a script is answering for a mobile? 13 years, 9 months ago #3488

  • cabillic
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
Hi,

I want to make a mobile version of my internal web site in which I have a lot of custom php scripts that generates article contents. Thus, I installed the mobile Joomla! extension. But I need to adapt my scripts for the mobile template.

Is there a way for my php scripts todetect (in php) is has been called from a mobile ? And how a script knows that the mobile template is running of the default one?

Thanks,
Gilbert.

Re: How to detect in php that a script is answering for a mobile? 13 years, 9 months ago #3489

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
The simplest check is
if(defined('_MJ'))
{
// mobile
}

but the check will fail if your scripts run before Joomla triggers onAfterRoute event.
  • Page:
  • 1
Time to create page: 0.10 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.