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!

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.