2.7. Instructions

2.7.1. Section
2.7.2. Tree
2.7.3. Pagesystem
2.7.4. Conditions
2.7.5. Separator
2.7.6. Var
2.7.7. Include
2.7.8. Place
2.7.9. Default
2.7.10. Capture
2.7.11. For
2.7.12. Foreach
2.7.13. Php
2.7.14. Literal
2.7.15. Dynamic
2.7.16. Bind
2.7.17. Insert
2.7.18. BindEvent
2.7.19. BindGroup

Instructions define most of the logic in the template. Using them, you may define, where the lists of data are, what parts of the content are shown conditionally etc. They make use of OPT tags explained above, however they support some optional simplifications you can use (but only with the instructions!):

  1. Single tags do not have to be ended with slash. {include="`file.tpl`"} is the same, as {include="`file.tpl`"/}
  2. Alternative tags do not have to be ended with "else" - it depends on the instruction.

An instruction may extend the $opt special block and add new features to it.

In OPT 1.1.0, the attributes were introduced. They are special attributes of normal HTML tags that are parsed by OPT instructions. Consider the following example. A section is an instruction to make lists. We want to mark the first element of the list. To do this, we use the attribute opt:first for the list item element:

Example 2.23. Single tags

<ul>
{section=list}
<li opt:first="list">{$list.title}</li>
{/section}
</ul>

Now, for the first element of the list, the attribute will change into class="first", so that we can define the style in the CSS. For the rest, it does nothing.

Note: you have to define a namespace for all the attributes!

The instruction reference contains also the information about the usage from the script-side indented for PHP programmers. These parts are marked with the blue bar.