I want to have the theme change automatically based on whether the user is on a pda or a desktop/laptop
I thought the answer was in detecting browsers but after looking at available scripts for detecting browsers i realized that wasn't the answer. A lot of pda browsers SAY they are mozilla and so do some desktop browsers so theme selection based on browser isn't viable unless you are only redirecting WAP browsers (they are easier to spot)
So I looked into detecting screen resolution. There are some scripts within some PHP webstats but i haven't had the time to dig through that.
I did find this though
Code
<script language="Javascript"><!--
// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************
if (screen.width <= 1023) {
document.location = "small_window.htm";
}
if (screen.width > 1024) {
document.location = "actual_site.htm";
}
//--></script>
// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************
if (screen.width <= 1023) {
document.location = "small_window.htm";
}
if (screen.width > 1024) {
document.location = "actual_site.htm";
}
//--></script>
SO we could make it really easy by only using half that script in header.php
Code
<script language="Javascript"><!--
if (screen.width <= 1023) {
document.location = "index.php?theme=mobile";
}
//--></script>
if (screen.width <= 1023) {
document.location = "index.php?theme=mobile";
}
//--></script>
so that would reload the index with the theme variable in the URL
then after that in header.php (maybe after the pnapi include) we could put this
Code
which would see if the browser was redirected by seeing the variable in the URL and UNSET the theme variable and reassign it the value of 'mobile' so when it came to load the theme it called the mobile theme.
Notice that both scripts don't do anything if the browser is a desktop size?
Can anyone help further this? Someone more knowledgeable? maybe a PN developer?
I believe this to be useful. It would help a lot of webmasters display their content to their mobile users more effectively. If we could iron this out it would be possible to put a 'enable PDA user redirect' check box in the settings to turn this on.
I appreciate any constructive feedback
