Skip to Content Skip to Menu

[SOLVED] Mobile Tab Layout

  • clickmo
  • clickmo
  • OFFLINE
  • Posts: 55
  • Thanks: 1
  • Karma: 1
13 years 1 month ago - 13 years 1 month 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
Code:
$mobile_browser = false; // set mobile browser as false till we can prove otherwise $user_agent = $_SERVER['HTTP_USER_AGENT'];

Next do Mobile Checks
Code:
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
Code:
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
Last edit: 13 years 1 month ago by clickmo.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum