mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-11 17:43:50 +01:00
134 lines
4.5 KiB
XML
134 lines
4.5 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 1.1 Maintainer: thomasgm Status: ready -->
|
|
<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>Nome do Atributo</entry>
|
|
<entry>Tipo</entry>
|
|
<entry>Obrigatório</entry>
|
|
<entry>Padrão</entry>
|
|
<entry>Descrição</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>file</entry>
|
|
<entry>string</entry>
|
|
<entry>Sim</entry>
|
|
<entry><emphasis>n/d</emphasis></entry>
|
|
<entry>O nome do arquivo de template a incluir</entry>
|
|
</row>
|
|
<row>
|
|
<entry>assign</entry>
|
|
<entry>string</entry>
|
|
<entry>Não</entry>
|
|
<entry><emphasis>n/d</emphasis></entry>
|
|
<entry>O nome de uma variável que irá
|
|
conter toda a saída do template</entry>
|
|
</row>
|
|
<row>
|
|
<entry>[var ...]</entry>
|
|
<entry>[var type]</entry>
|
|
<entry>Não</entry>
|
|
<entry><emphasis>n/d</emphasis></entry>
|
|
<entry>Variável para passar localmente para o template</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
<para>
|
|
Tags include são usadas para incluir outros templates no template
|
|
atual. Quaisquer variáveis disponíveis no template atual também estarão
|
|
disponíveis junto com template incluído. A tag include deve ter o atributo
|
|
"file", o qual contém o caminho do arquivo a incluir.
|
|
</para>
|
|
<para>
|
|
Você pode opcionalmente passar o atributo <emphasis>assign</emphasis>,
|
|
o qual irá especificar o nome de uma variável de template para a qual
|
|
conterá todo o conteúdo do <emphasis>include</emphasis> ao
|
|
invés de mostrá-lo.
|
|
</para>
|
|
<example>
|
|
<title>function include</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{include file="cabecalho.tpl"}
|
|
|
|
{* O conteúdo do template vem aqui *}
|
|
|
|
{include file="rodape.tpl"}
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<para>
|
|
Você pode também passar variáveis para o template incluído como atributos.
|
|
Quaisquer variáveis passadas para um template incluído como atributos
|
|
estão disponíveis somente dentro do escopo do template incluído.
|
|
As variáveis passadas como atributos sobrescrevem as variáveis de
|
|
template atuais, no caso de ambas terem o mesmo nome.
|
|
</para>
|
|
<example>
|
|
<title>Função include passando variáveis</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{include file="cabecalho.tpl" title="Menu Principal" table_bgcolor="#c0c0c0"}
|
|
|
|
{* O conteúdo de template vem aqui *}
|
|
|
|
{include file="rodape.tpl" logo="http://meu.dominio.com/logo.gif"}
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<para>
|
|
Use a sintaxe de <link
|
|
linkend="template.resources">template resources</link> para
|
|
incluir arquivos fora do diretório $template_dir.
|
|
</para>
|
|
<example>
|
|
<title>Exemplos de recursos para a função include</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{* caminho absoluto *}
|
|
{include file="/usr/local/include/templates/cabecalho.tpl"}
|
|
|
|
{* caminho absoluto (idem) *}
|
|
{include file="file:/usr/local/include/templates/cabecalho.tpl"}
|
|
|
|
{* caminho absoluto do windows (DEVE usar o prefixo "file:") *}
|
|
{include file="file:C:/www/pub/templates/cabecalho.tpl"}
|
|
|
|
{* incluir a partir do recurso de template chamado "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
|
|
--> |