Overview
The [before]
and [after]
Template tag blocks are used to output a piece in your template that will only be output before the ‘loop’ portion of the template and after it. This is primarily used for Table heading blocks <table><thead>...</thead><tbody>
(and table ending blocks </tbody></table>
) and the opening Un-ordered List <ul>
and closing un-ordered list </ul>
. NOTE: Magic Tags are not processed inside the Before and After blocks, so they cannot be used to provide ‘totals’ or ‘counts’ or anything else of that nature.
Usage
You also have access to [before]
and [after]
blocks. These can be used to set code that runs before or after all iterations of a template. This means that if you call a template in a against a loop or using the Pods shortcode, so that it is used to show multiple items, the [before]
and [after]
blocks will only run once.
This avoids the issue where the shortcode
[pods name="books" template="Books - List"]
If it called a template like this:
<ul> <li>{@post_title}</li> </ul>
Would output:
<ul> <li>Book One</li> </ul> <ul> <li>Book Two</li> </ul> <ul> <li>Book Three</li> </ul>
That template could be rewritten as:
[before]<ul>[/before] <li>{@post_title}</li> [after]</ul>[/after]
Which will result in:
<ul> <li>Book One</li> <li>Book Two</li> <li>Book Three</li> </ul>