https://www.icyphoenix.com/viewtopic.php?f=35&t=7636 ----------------------------------- Xusqui Sun 13 Feb, 2011 16:43 Mobile Detection ----------------------------------- This is a small add-on to detect mobile navigation in the forum. Then ask if you want to see in an adapted resolution for the mobile (use the lofi mode with a specific template). Only works for iPhone, Android and Nokia phones. 1st step. Create a new file called mobiledetect.js and place it in your root forum: [code] function detectMobile() { if (document.cookie.indexOf("mobile_redirect=false") < 0) { if (!navigator.userAgent.match(/Opera/i)) { if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (confirm("This site has an specific template foro iPhone uses. Click OK to view.")) { document.cookie = "mobile_redirect=false"; window.location = "./mobile.php?lofi=1"; } else { setMobileCookies(); } } else if(navigator.userAgent.match(/android/i)) { if (confirm("This site has an specific template for Android users. Click OK to view.")) { document.cookie = "mobile_redirect=false"; window.location = "./mobile.php?lofi=1"; } else { setMobileCookies(); } } else if((navigator.userAgent.match(/Symbian/i)) || (navigator.userAgent.match(/Nokia/i))) { if (confirm("This site has an specific templare foro Nokia uses. Click OK to view.")) { document.cookie = "mobile_redirect=false"; window.location = "./mobile.php?lofi=1"; } else { setMobileCookies(); } } } } } function setMobileCookies() { var date = new Date(); var days = 60; date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+ date.toGMTString(); document.cookie = "mobile_redirect=false" + expires; } detectMobile();[/code] 2nd step. Open templates/default/overall_header.tpl search for [code] [/code] After add [code][/code] 3rd step. Login as admin and go to CMS system. Go to "Personal Pages" and create a new one called "mobile.php" based upon 2column.tpl 4th step Edit the just created "mobile" page and add the blocks you wish. In my case I only use one "News" block. That's all. You can see how it works (if you have iPhone, android or Nokia) at http://www.ka-tet-corp.com/portal2.0/ Tchüss!!! ----------------------------------- spydie Sun 13 Feb, 2011 19:37 Re: Mobile Detection ----------------------------------- another good one Xusqui [hr] still on .27 ?? ----------------------------------- TheSteffen Sun 13 Feb, 2011 19:52 Re: Mobile Detection ----------------------------------- Great work [b]Xusqui[/b], thanks for sharing it Is it for Icy Phoenix 1.2.0.27 or IP 1.3? ----------------------------------- Xusqui Mon 14 Feb, 2011 08:58 Re: Mobile Detection ----------------------------------- It's for 1.3 but should work also on .27 ... You're welcome!! ----------------------------------- Costa Mon 14 Feb, 2011 09:59 Re: Mobile Detection ----------------------------------- Very nice but I am worried that there will be a special problem with these When a Post or a pages of the site will have this function and when have more visits with phones then google for the next visitor will propose these Post or pages in the format of the phone. So many many next visitors will come with a normal PC will see something for iphon I faced a similar issue with lofi and print view which referred to the google mu particularly negative Do not forget that new guests visitors for sites are usually> 70 from search engines and the greater part of the search engines are google ----------------------------------- spydie Tue 05 Apr, 2011 13:30 Re: Mobile Detection ----------------------------------- hm. what about including another function to determine if the user is using mobile or Pc, so mobile only triggers, if a mobile is detected should be easy