Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New Plugin
#1
Hey guys,
I am working on my first plugin. Basically I would like my plugin to detect the user's browser
and then set the theme correctly. Basically it will automatically set the theme to IPhone Theme if
a user visits the site from an IPhone.

I have written the back end of the script (V.1.0 will have no options V.2.O will have the option to select
witch theme to switch to for an IPhone).

So here are my questions:
1. How should I go about automatically changing the theme for the iphone?
Code:
<?php if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE)  
        { 'THIS WILL BE MY CODE TO CHANGE THE THEME }  
        ?>
That is the code I will be using to detect the browser.

2. What Plugin Hooks do I need to use for this to work (I already have the back end working...)

3. Would any one actually be interested in this other than me?

Thank you in advance for any help!!!
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply
#2
OWS_Matthew Wrote:How should I go about automatically changing the theme for the iphone?
Code:
<?php
   global $TEMPLATE;
   if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE) {
      $TEMPLATE = 'iphone_theme_name'; // the theme’s folder name, /themes/iphone_theme_name/template.php etc.
   }
?>
OWS_Matthew Wrote:What Plugin Hooks do I need to use for this to work?
The above code should run on the ‘index-pretemplate’ hook.

Please note that I did not take the time to test everything I’ve said here. But it should work… I guess.
OWS_Matthew Wrote:Would any one actually be interested in this other than me?
I think there will be, especially once version 2 gives you a nice GUI to configure it. And, as there already is an iPhone theme, this could be used almost immediately.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
This is what I figured, do you by chance know how I could stop the set theme from being included if it is an iPhone?

Also to change the theme you just include the template.php file out of the theme folder?
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply
#4
The code I showed above should (as I said, I didn’t test it) completely overwrite the default theme with whatever theme you put there. In the code example you would use a theme called ‘iphone_theme_name’. It is the only thing you should need to do, overwrite $TEMPLATE with the name of the theme you want to use.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#5
I am sorry about that, I just read over you last post to fast!

This seems to work, I will clean up my code, fix some grammar issues,
then v.1.0 should be ready to be released!

Thank you for all the help!!!
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply




Users browsing this thread: 1 Guest(s)