newbtophp Posted September 27, 2010 Share Posted September 27, 2010 Heya! I've coded a small php template parser, so templates can be easily parsed, and the variables within the templates are like {variable_name} e.g. <title>{title}</title> Can you suggest me possible if/else statement syntax? I've thought of doing something like: {if {logged_in}: TRUE} Your logged in... {else} Your not... {/if} and... {if {logged_in}: TRUE} Your logged in... {/if} The above demonstrates basic if/else template syntax (it checks if the variable logged_in == true), but since I'm more of a coder then designer, was wondering if I can have your input (so designers can easily understand the syntax without knowledge of server-side coding). Cheers! Link to comment https://forums.phpfreaks.com/topic/214538-need-some-advicesuggestions-on-template-syntax/ Share on other sites More sharing options...
Psycho Posted September 27, 2010 Share Posted September 27, 2010 Since these primarily used as placeholders I don't see why you would have the designer enter in hard coded text. Instead, have the designer define two messages: $logged_in_msg & $not_logged_in_msg Then, assuming there is a "system" variabled called $logged_in which has a value of true or false, the designer could do something like this: [ if ($logged_in) { $logged_in_msg } else { $not_logged_in_msg } ] Although, I would probably modify that after I develop the code to actually make the replacements for the if/else conditions. That process will probably reveal a more elegant way of creating the if/else conditions that will be easy to code for. Link to comment https://forums.phpfreaks.com/topic/214538-need-some-advicesuggestions-on-template-syntax/#findComment-1116391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.