mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-25 02:11:37 +02:00
124 lines
4.4 KiB
XML
124 lines
4.4 KiB
XML
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
|
|
<!-- $Revision$ -->
|
||
|
|
<sect1 id="language.function.include">
|
||
|
|
<title>include</title>
|
||
|
|
<informaltable frame="all">
|
||
|
|
<tgroup cols="5">
|
||
|
|
<colspec colname="param" align="center" />
|
||
|
|
<colspec colname="type" align="center" />
|
||
|
|
<colspec colname="required" align="center" />
|
||
|
|
<colspec colname="default" align="center" />
|
||
|
|
<colspec colname="desc" />
|
||
|
|
<thead>
|
||
|
|
<row>
|
||
|
|
<entry>Attribute Name</entry>
|
||
|
|
<entry>Type</entry>
|
||
|
|
<entry>Required</entry>
|
||
|
|
<entry>Default</entry>
|
||
|
|
<entry>Description</entry>
|
||
|
|
</row>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
<row>
|
||
|
|
<entry>file</entry>
|
||
|
|
<entry>string</entry>
|
||
|
|
<entry>Yes</entry>
|
||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
||
|
|
<entry>The name of the template file to include</entry>
|
||
|
|
</row>
|
||
|
|
<row>
|
||
|
|
<entry>assign</entry>
|
||
|
|
<entry>string</entry>
|
||
|
|
<entry>No</entry>
|
||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
||
|
|
<entry>The name of the variable that the output of
|
||
|
|
include will be assigned to</entry>
|
||
|
|
</row>
|
||
|
|
<row>
|
||
|
|
<entry>[var ...]</entry>
|
||
|
|
<entry>[var type]</entry>
|
||
|
|
<entry>No</entry>
|
||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
||
|
|
<entry>variable to pass local to template</entry>
|
||
|
|
</row>
|
||
|
|
</tbody>
|
||
|
|
</tgroup>
|
||
|
|
</informaltable>
|
||
|
|
<para>
|
||
|
|
Include tags are used for including other templates in the current
|
||
|
|
template. Any variables available in the current template are also
|
||
|
|
available within the included template. The include tag must have
|
||
|
|
the attribute "file", which contains the template resource path.
|
||
|
|
</para>
|
||
|
|
<para>
|
||
|
|
You can optionally pass the <emphasis>assign</emphasis> attribute,
|
||
|
|
which will specify a template variable name that the output of
|
||
|
|
<emphasis>include</emphasis> will be assigned to instead of
|
||
|
|
displayed.
|
||
|
|
</para>
|
||
|
|
<example>
|
||
|
|
<title>function include</title>
|
||
|
|
<programlisting>
|
||
|
|
{include file="header.tpl"}
|
||
|
|
|
||
|
|
{* body of template goes here *}
|
||
|
|
|
||
|
|
{include file="footer.tpl"}</programlisting>
|
||
|
|
</example>
|
||
|
|
<para>
|
||
|
|
You can also pass variables to included templates as attributes.
|
||
|
|
Any variables explicitly passed to an included template as
|
||
|
|
attributes are only available within the scope of the included
|
||
|
|
file. Attribute variables override current template variables, in
|
||
|
|
the case they are named alike.
|
||
|
|
</para>
|
||
|
|
<example>
|
||
|
|
<title>function include passing variables</title>
|
||
|
|
<programlisting>
|
||
|
|
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||
|
|
|
||
|
|
{* body of template goes here *}
|
||
|
|
|
||
|
|
{include file="footer.tpl" logo="http://my.domain.com/logo.gif"}</programlisting>
|
||
|
|
</example>
|
||
|
|
<para>
|
||
|
|
Use the syntax for <link
|
||
|
|
linkend="template.resources">template resources</link> to
|
||
|
|
include files outside of the $template_dir directory.
|
||
|
|
</para>
|
||
|
|
<example>
|
||
|
|
<title>function include template resource examples</title>
|
||
|
|
<programlisting>
|
||
|
|
{* absolute filepath *}
|
||
|
|
{include file="/usr/local/include/templates/header.tpl"}
|
||
|
|
|
||
|
|
{* absolute filepath (same thing) *}
|
||
|
|
{include file="file:/usr/local/include/templates/header.tpl"}
|
||
|
|
|
||
|
|
{* windows absolute filepath (MUST use "file:" prefix) *}
|
||
|
|
{include file="file:C:/www/pub/templates/header.tpl"}
|
||
|
|
|
||
|
|
{* include from template resource named "db" *}
|
||
|
|
{include file="db:header.tpl"}</programlisting>
|
||
|
|
</example>
|
||
|
|
</sect1>
|
||
|
|
<!-- Keep this comment at the end of the file
|
||
|
|
Local variables:
|
||
|
|
mode: sgml
|
||
|
|
sgml-omittag:t
|
||
|
|
sgml-shorttag:t
|
||
|
|
sgml-minimize-attributes:nil
|
||
|
|
sgml-always-quote-attributes:t
|
||
|
|
sgml-indent-step:1
|
||
|
|
sgml-indent-data:t
|
||
|
|
indent-tabs-mode:nil
|
||
|
|
sgml-parent-document:nil
|
||
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
||
|
|
sgml-exposed-tags:nil
|
||
|
|
sgml-local-catalogs:nil
|
||
|
|
sgml-local-ecat-files:nil
|
||
|
|
End:
|
||
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
|
|
vim: et tw=78 syn=sgml
|
||
|
|
vi: ts=1 sw=1
|
||
|
|
-->
|