Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
php if statement
#26
So it is working then?
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#27
It works fine without checking to see if the iPhone file exists.
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply
#28
Al right, I’ll have class soon but in about 2 hours I’ll get back to you with one that does check for theme existence (if nobody has beaten me to it by then). I will not write the admin section though, but I can give you some pointers if you’d like Smile
“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
#29
Zegnåt Wrote:...I’ll get back to you with one that does check for theme existence (if nobody has beaten me to it by then).
I had posted a working example of checking theme existence but deleted it because, although I requested it, I do agree with internet24 that keeping it simple works best.
Code:
add_hook('index-pretemplate','sitc_process');
function sitc_process() {
    global $TEMPLATE;
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') == true) {
        if (is_dir(GSTHEMESPATH.'iPhone')) { $TEMPLATE = 'iPhone'; }
    }
}

I've actually tweaked it some (see attachment) to change the theme based on $_SERVER["HTTP_HOST"], for example "m.example.com", as this is the recommended way to serve a mobile version of your website.
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Reply
#30
As this is to be released as a plugin and you have no control over the users file structure it’s not really best practise to not check for the theme’s existence. Because setting $TEMPLATE to a non-existing theme does not sound like a very good idea.
“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
#31
I woke up Big Grin.

For some reason my attachment didn't show up. I'm going to try to attach it again.

Edit: Nope, I couldn't upload it. Is there something wrong with my (the Member) permissions?
Reply
#32
@Sal I am glad to say your code works fine, with one small adjustment.
I had to change
Code:
add_hook('index-pretemplate','sitc_process');
to
Code:
add_action('index-pretemplate', 'sitc_process');

@everyone
You guys keep telling me to keep this simple, I am not quite understanding how
this will turn this plugin into something that isn't advanced? My main reasoning for
the plugin to check for the file existence of the 'iPhone' file is so that if it happened to
accidentally get deleted, or they install the plugin before the theme, it will not crash there
website.

@baris have you tried to zip the .php file and upload it?

@zegnat the only thing that has prevented me from add features to this (as in the admin section)
is because I am new to php, I can't get a grasp on php and simplexml. I wouldn't even know where
to start to read an xml file with php...

thank you all!
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply
#33
@OWS; yes I did but couldn't Sad. I uploaded to my own FTP server now, you can download it from below:

(edit: removed the link)
Reply
#34
@baris I have already gotten a working version of this now, thanks to @sal.

I believe the issue with the script me and you were using evolved file_exists()
@sal used is_dir() and it works.

Thanks to every one who attempted to assist me with this and a big thanks to @Sal.

I will be releasing this as an update to the previous plugin soon!
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply




Users browsing this thread: 1 Guest(s)