I'm creating a system where users can create their own themes, styles, and templates. I'm storing their page templates in a MySQL database and currently I've written a small replace script that uses tags so the user can define where content should go in their template elements. The script replaces their tags with their content during when the page is rendered.
What I want to do now is add the ability for them to define a section conditionally - so for example they might have an element in their template that looks like this:
<h1 class="entry-title">
<span class="top-left-ribbon"></span>
@titlebar>heading
<span class="sub-heading">@titlebar>subheading</span>
<span class="right-ribbon"></span>
</h1>
Replacing the titlebar heading and subheading with the required values is no problem, but I can't figure out how to do the following and replace the conditionals with PHP if statements and have it process.
<h1 class="entry-title">
<span class="top-left-ribbon"></span>
@titlebar>heading
@titlebar?subheading
<span class="sub-heading" >@titlebar>subheading</span>
<span class="right-ribbon"></span>
@end?
</h1>
Basically I would want to replace:
@titlebar?subheading
@end?
with:
if($titlebar->subheading){ }
and process through PHP appropriately. Any suggestions would be appreciated.