Icy Phoenix

     
 


Post new topic  Reply to topic 
Page 1 of 1
 
 
Reply with quote Download Post 
Post 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: [Download] [Hide]
  1. function detectMobile() { 
  2.     if (document.cookie.indexOf("mobile_redirect=false") < 0) { 
  3.         if (!navigator.userAgent.match(/Opera/i)) { 
  4.             if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { 
  5.                 if (confirm("This site has an specific template foro iPhone uses. Click OK to view.")) {             
  6.                     document.cookie = "mobile_redirect=false";  
  7.                     window.location = "./mobile.php?lofi=1"; 
  8.                 } else { 
  9.                     setMobileCookies(); 
  10.                 } 
  11.             } else if(navigator.userAgent.match(/android/i)) { 
  12.                 if (confirm("This site has an specific template for Android users. Click OK to view.")) {             
  13.                     document.cookie = "mobile_redirect=false";  
  14.                     window.location = "./mobile.php?lofi=1"; 
  15.                 } else { 
  16.                     setMobileCookies(); 
  17.                 } 
  18.             } else if((navigator.userAgent.match(/Symbian/i)) || (navigator.userAgent.match(/Nokia/i))) { 
  19.                 if (confirm("This site has an specific templare foro Nokia uses. Click OK to view.")) {             
  20.                     document.cookie = "mobile_redirect=false";  
  21.                     window.location = "./mobile.php?lofi=1"; 
  22.                 } else { 
  23.                     setMobileCookies(); 
  24.                 } 
  25.             } 
  26.              
  27.         } 
  28.     } 
  29.  
  30. function setMobileCookies() { 
  31.     var date = new Date(); 
  32.     var days = 60; 
  33.     date.setTime(date.getTime()+(days*24*60*60*1000)); 
  34.     var expires = "; expires="+ date.toGMTString(); 
  35.     document.cookie = "mobile_redirect=false" + expires;  
  36.  
  37. detectMobile(); 


2nd step.
Open templates/default/overall_header.tpl

search for
Code: [Download] [Hide]
  1. </head> 
  2. <body> 


After add
Code: [Download] [Hide]
  1. <script type="text/javascript" src="mobiledetect.js"></script> 


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!!!
 




____________
Icy Phoenix Latest 2.0 (working pending)
Style: Aphrodite and MG_Themes
Site: Spanish Stephen King fan forum
Mods: Medal System Mod. BBAntispam 1.2. Several own BBcodes.
 
XusquiSend private messageVisit poster's website  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Reply with quote Download Post 
Post Re: Mobile Detection 
 
another good one Xusqui




still on .27 ??
 




____________
Out of Order
 
spydieSend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Mobile Detection 
 
Great work Xusqui,
thanks for sharing it

Is it for Icy Phoenix 1.2.0.27 or IP 1.3?
 




____________
TheSteffen
Often SEARCH is the quickest way to get support.
IcyPhoenix German Support
 
TheSteffenSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Mobile Detection 
 
It's for 1.3 but should work also on .27

... You're welcome!!
 




____________
Icy Phoenix Latest 2.0 (working pending)
Style: Aphrodite and MG_Themes
Site: Spanish Stephen King fan forum
Mods: Medal System Mod. BBAntispam 1.2. Several own BBcodes.
 
XusquiSend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post 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
 



 
CostaSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post 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
 




____________
Out of Order
 
spydieSend private messageVisit poster's website  
Back to topPage bottom
Post new topic  Reply to topic  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events


  

 

  cron