[SOLVED] Mobile Tab Layout

12 years 7 months ago - 12 years 7 months ago #175780 by clickmo
Replied by clickmo on topic Re: Mobile Tab Layout
That's great. Exactly what I wanted to know. Just for anyone else looking to do this here are some pointers

The path to the file you are looking for is:
components\com_comprofiler\plugin\templates\default\default.php

Inside the render function you setup the variables
$mobile_browser   = false; // set mobile browser as false till we can prove otherwise
$user_agent       = $_SERVER['HTTP_USER_AGENT']; 

Next do Mobile Checks
switch(true){ 

		case (preg_match('/ipod/i',$user_agent)||preg_match('/iphone/i',$user_agent)); 
			$mobile_browser = $iphone;    
		break;
		case (preg_match('/android/i',$user_agent));  
			$mobile_browser = $android;
		break;
		case (preg_match('/opera mini/i',$user_agent)); 
			$mobile_browser = $opera;
		break;	
		case (preg_match('/blackberry/i',$user_agent)); 
			$mobile_browser = $blackberry;
		break;
		case (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i',$user_agent)); 
			$mobile_browser = $palm;
		break;
		case (preg_match('/(iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i',$user_agent)); 
			$mobile_browser = $windows;
		break;
		
		default;
			$mobile_browser = false; // set mobile browser to false
			$status = 'Desktop';
		break;
		}


After that you have a true of false value that you can check in an if statment
if(!mobile_browser)
{
	//Do desktop rendering
}
else
{
	//Do Mobile Rendering
}


if you wanted to you could also store a calue in the switch case so that you could detect what browser it was and display different rendering styles

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.151 seconds

Facebook Twitter LinkedIn