Include another template in the template.
{INCLUDE [ONCE] <INCLUDE PAGE>}
The <INCLUDE PAGE>
can be any of
the data types that are supported by the template
language (see Section 1.4.3, “Data types”).
By specifiying the keyword ONCE
before
the name of template to include, you can make sure that
that template is only included once per page.
Example 1.19. INCLUDE statement usage
{INCLUDE "paging"} {VAR include_page "cool_include_page"} {INCLUDE include_page} {INCLUDE ONCE "css"}
It is not possible to use a dynamic INCLUDE statement
(one where the <INCLUDE PAGE>
is set through a template variable) within a LOOP
statement, in case the included template needs to have
access to the active LOOP element. There is no problem if
you use a static INCLUDE statement (one where the
<INCLUDE PAGE>
is set through
a string value).
If you really need this kind of functionality though, you
can work around this limitation by assigning the active
LOOP element to a new template variable, prior to
including the dynamic
<INCLUDE PAGE>
. Example:
{! include_page holds the dynamic page to include } {VAR include_page "some_page"} {LOOP loop_variable} {! Makes loop_variable available as temp_variable in the include } {VAR temp_variable loop_variable} {INCLUDE include_page} {/LOOP loop_variable}
This way you can access the active LOOP element from the
included template through temp_variable
.
If you would access loop_variable
from there, you'd see that it does not contain the
active LOOP element, but the full array that you are
looping over instead.