$ifcontent$ Macro
The new $ifcontent$ macro allows to create dynamic layouts depending on content of article fields.
Unlike $checkfield$ it doesn't just output true or false as an indicator for field content. With $ifcontent$ it's possible to output the complete content of a field together with appropriate HTML. So you don't rely on JavaScript for content dependent layout (e.g. for optional images) anymore. Additionally, if/else structures can now be implemented, too. Nested structures are not supported.
Note: After updating your Siteseed installation you should empty the CACHE database table of your current Siteseed installation. Just delete the entries of the CACHE table, don't delete the table itself! You may use e.g. phpMyAdmin for that.
Usage Examples of $ifcontent$
And that's how it works:
Example 1 - General Usage:
$ifcontentn$ hello world $end$ |
The field #n is checked for content. If it is not empty, the string between $ifcontentn$ and $end$ is displayed. In this case that would be the string hello world. Of course, macros inside of $ifcontent$ structures will be evaluated, too. |
Example 2 - General Usage:
$ifcontentn$ foo $else$ bar $end$ |
The field #n is checked for content. If it is not empty, the string (foo) between $ifcontentn$ and $else$ is displayed. Otherwise the string (bar) between $else$ and $end$ would be displayed. Of course, macros inside of $ifcontent$ structures will also be evaluated. |
Example 3:
$ifcontent5$ <h1> $5$ </h1> $end$ |
Field #5 of the current article is checked for content. If it's not empty, the string '<h1> $5$ </h1>' is taken, evaluated ($5$ is replaced by the content of field #5), and displayed. |
Example 4:
$ifcontent6$ $5$ $else$ <h2>There is no content in field #6</h2> $end$ |
Field #6 is evaluated for content. If it keeps content, macro $5$ is evaluated, replaced by the content of field 5, and displayed. Otherwise the string '<h2>There is no content in field #6</h2>' is displayed. |
Example #3:
$ifcontent5,6,7$ <h1>There is content in field #5, #6, and #7</h1> $else$ <h2>There is no content in field #5, #6, and #7</h2> $end$ |
Like with $checkfield$ it is also possible to check several fields at the same time. In this example field #5, field #6, and field #7 are checked. If they all keep content, the string between $ifcontent5,6,7$ and $else$ is displayed, otherwise the string between $else$ and $end$. |
Of course, it can also be used like $checkfield$ macro:
| $ifcontent4$true$else$false$end$ |
This example would be equivalent to $checkfield4$. |
