Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 8377d4bb25a3992aad680df2952f4b71 > files > 81

php-smarty-doc-2.6.26-1mdv2010.0.noarch.rpm

<HTML
><HEAD
><TITLE
>{include}</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Smarty Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Built-in Functions"
HREF="language.builtin.functions.html"><LINK
REL="PREVIOUS"
TITLE="{if},{elseif},{else}"
HREF="language.function.if.html"><LINK
REL="NEXT"
TITLE="{include_php}"
HREF="language.function.include.php.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Smarty Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="language.function.if.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 7. Built-in Functions</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="language.function.include.php.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="language.function.include"
></A
>{include}</H1
><P
>&#13;  <TT
CLASS="varname"
>{include}</TT
> 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.
  </P
><P
></P
><UL
><LI
><P
>&#13;  The <TT
CLASS="varname"
>{include}</TT
> tag must have
  the  <TT
CLASS="parameter"
><I
>file</I
></TT
> attribute
  which contains the template resource path.
  </P
></LI
><LI
><P
>&#13;  Setting the optional <TT
CLASS="parameter"
><I
>assign</I
></TT
> attribute
   specifies the template variable that the output of
  <TT
CLASS="varname"
>{include}</TT
> is assigned to, instead of being displayed. Similar to
  <A
HREF="language.custom.functions.html#language.function.assign"
><TT
CLASS="varname"
>{assign}</TT
></A
>.
 </P
></LI
><LI
><P
>&#13;  Variables can be passed to included templates as
  <A
HREF="language.syntax.attributes.html"
>attributes</A
>.
  Any variables explicitly passed to an included template
   are only available within the scope of the included
  file. Attribute variables override current template variables, in
  the case when they are named the same.
 </P
></LI
><LI
><P
>&#13;  All assigned variable values are restored after the scope of the
  included template is left. This means you can use all variables from
  the including template inside the included template. But changes to
  variables inside the included template are not visible inside the
  including template after the <TT
CLASS="varname"
>{include}</TT
> statement.
  </P
></LI
><LI
><P
>&#13;  Use the syntax for <A
HREF="template.resources.html"
>template resources</A
> to
  <TT
CLASS="varname"
>{include}</TT
> files outside of the
  <A
HREF="api.variables.html#variable.template.dir"
><TT
CLASS="parameter"
><I
>$template_dir</I
></TT
></A
>  directory.
  </P
></LI
></UL
><DIV
CLASS="informaltable"
><A
NAME="AEN2006"
></A
><P
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Attribute Name</TH
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Type</TH
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Required</TH
><TH
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Default</TH
><TH
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>file</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>string</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>Yes</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>n/a</I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The name of the template file to include</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>assign</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>string</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>No</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>n/a</I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The name of the variable that the output of
      include will be assigned to</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>[var ...]</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>[var type]</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>No</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>n/a</I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>variable to pass local to template</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2042"
></A
><P
><B
>Example 7-17. Simple {include} example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>&#60;html&#62;
&#60;head&#62;
  &#60;title&#62;{$title}&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
{include file='page_header.tpl'}

{* body of template goes here, the $tpl_name variable
   is replaced with a value eg 'contact.tpl'
*}
{include file="$tpl_name.tpl"}

{include file='page_footer.tpl'}
&#60;/body&#62;
&#60;/html&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2045"
></A
><P
><B
>Example 7-18. {include} passing variables</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>{include file='links.tpl' title='Newest links' links=$link_array}
{* body of template goes here *}
{include file='footer.tpl' foo='bar'}</PRE
></TD
></TR
></TABLE
><P
>The template above includes the example <TT
CLASS="filename"
>links.tpl</TT
> below</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>&#60;div id="box"&#62;
&#60;h3&#62;{$title}{/h3&#62;
&#60;ul&#62;
{foreach from=$links item=l}
.. do stuff  ...
&#60;/foreach}
&#60;/ul&#62;
&#60;/div&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2051"
></A
><P
><B
>Example 7-19. {include} and assign to variable</B
></P
><P
>This example assigns the contents of <TT
CLASS="filename"
>nav.tpl</TT
>
    to the <TT
CLASS="varname"
>$navbar</TT
> variable,
   which is then output at both the top and bottom of the page.
   </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>&#60;body&#62;
  {include file='nav.tpl' assign=navbar}
  {include file='header.tpl' title='Smarty is cool'}
    {$navbar}
    {* body of template goes here *}
    {$navbar}
  {include file='footer.tpl'}
&#60;/body&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2057"
></A
><P
><B
>Example 7-20. Various {include} resource examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="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'}

{* include a $variable template - eg $module = 'contacts' *}
{include file="$module.tpl"}

{* wont work as its single quotes ie no variable substitution *}
{include file='$module.tpl'}

{* include a multi $variable template - eg amber/links.view.tpl *}
{include file="$style_dir/$module.$view.tpl"}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;  See also
  <A
HREF="language.function.include.php.html"
><TT
CLASS="varname"
>{include_php}</TT
></A
>,
  <A
HREF="language.function.insert.html"
><TT
CLASS="varname"
>{insert}</TT
></A
>,
  <A
HREF="language.function.php.html"
><TT
CLASS="varname"
>{php}</TT
></A
>,
  <A
HREF="template.resources.html"
>template resources</A
> and
  <A
HREF="tips.componentized.templates.html"
>componentized templates</A
>.
 </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="language.function.if.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="language.function.include.php.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>{if},{elseif},{else}</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="language.builtin.functions.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>{include_php}</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>