Welcome, Guest
Username Password: Remember me

using mobile detection + redirection on non-joomla site
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: using mobile detection + redirection on non-joomla site

using mobile detection + redirection on non-joomla site 13 years, 5 months ago #4418

  • steveb123
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
I've just started using mobile joomla & am thinking about using it to develop mobile sites where the PC websites already exist (i.e. hosted on a different domain) and haven't been built using joomla

I want to focus my time & efforts on developing the mobile sites (i.e. i'm not going to rebuild the existing website using joomla) and just need a really simple, lightweight method of detecting & redirecting from www.anysite.com to m.anysite.com, I'll then use mobile joomla features to handle all of the template display side of things for iphone, xhtml etc

So, do you know if there is a code snippet available that would allow me to use the device detection + redirect capability on another domain irrespective of whether or not joomla/mobile joomla is installed on that server? I doubt it's the case and am assuming I'll need to look elsewhere for this capability (e.g. device atlas or similar service), but if anyone knows a way...

Re: using mobile detection + redirection on non-joomla site 13 years, 5 months ago #4482

  • borussentv
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
This function deliver you a true or false value, depending if a mobile device is used. You can just call this function and do then whatever you want. 


function mobilecheck(){  	 $mobile_browser = '0';	 if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {	 $mobile_browser++;	 }	  	 if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {	 $mobile_browser++;	 }    	   $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));	 $mobile_agents = array(	 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',	 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno', 'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',	 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',	 'newt','noki','oper','palm','pana','pant','phil','play','port','prox',	 'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',	 'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',	 'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',	 'wapr','webc','winw','winw','xda ','xda-');	  	 if (in_array($mobile_ua,$mobile_agents)) {	 $mobile_browser++;	 }	  	 if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) {	 $mobile_browser++;	 }	  	 if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows') > 0) {	 $mobile_browser = 0;	 }	 if ($mobile_browser > 0) 	 {	   return true;	 }	 else	 {	 return false;}}


An alternative to the code above but more complex solution is the Tera-WURFL project, which is also used by mobile joomla.

For redirecting you can use e.g. php header
Last Edit: 13 years, 5 months ago by borussentv.
  • 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.