Jump to content

Need some advice/suggestions on template syntax.


newbtophp

Recommended Posts

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!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.