ComicCMS User Manual


Template Structures :: The If/Else Statement

To do advanced things in your templates it can be useful to have logic structures. For instance if your comic doesn't have a title then there's no need to create the section you would display that in. If there is a title, print box with title, otherwise print nothing. That's what you want, so how do you tell ComicCMS to do it? Well: {{if:comic_title}}
  <div id="title">Comic Title: <h2>{{comic_title}}</h2></div>
Did you get that?

We're checking whether the variable {{comic_title}} has anything in it by appending if: to the beginning, thus creating {{if:comic_title}}. ComicCMS now knows when you want things to change, but does it just ignore all the rest of the template if there is no title? No, we want to stop this condition and so we put in {{endif}} as a marker for that. So everything between {{if:comic_title}} and {{endif}} is conditional, and everything outside of that is unaffected.

Cool. Now just one more thing, {{else}}. It's not too hard to work this one out, it's how you tell ComicCMS to do something else if the if statement was false instead of doing nothing. Here's an example: {{if:comic_title}}
  <h2>Untitled Comic</h2>
The oddity to note here is that the {{else}} is now the marker for the end of the if statement and the {{endif}} is the marker for the end of the else statement.

Notice: Please note that ComicCMS is currently restricted and cannot handle nested statements. e.g: {{if:comic_title}}
Will not work as expected. We are sorry for this restriction and are trying our best to lift it in later versions of ComicCMS

ComicCMS, free php webcomic management software Copyright © 2007 Steve H