Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>{include_php}</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="{include}"
HREF="language.function.include.html"><LINK
REL="NEXT"
TITLE="{insert}"
HREF="language.function.insert.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.include.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.insert.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.php"
></A
>{include_php}</H1
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Technical Note: </B
>
    <TT
CLASS="varname"
>{include_php}</TT
> is pretty much deprecated from Smarty, you can
    accomplish the same functionality via a custom template function.
    The only reason to use <TT
CLASS="varname"
>{include_php}</TT
> is if you really have a need to
    quarantine the php function away from the
    <A
HREF="variable.plugins.dir.html"
><TT
CLASS="filename"
>plugins/</TT
></A
>
    directory or your
    application code. See the <A
HREF="tips.componentized.templates.html"
>componentized template
    example</A
> for details.
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="informaltable"
><A
NAME="AEN2079"
></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 php file to include</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>once</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>boolean</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
>No</TD
><TD
WIDTH="20%"
ALIGN="CENTER"
VALIGN="MIDDLE"
><SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
><TT
CLASS="constant"
>TRUE</TT
></I
></SPAN
></TD
><TD
WIDTH="20%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>whether or not to include the php file more than
      once if included multiple times</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_php will be assigned to</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
><P
>&#13;  <TT
CLASS="varname"
>{include_php}</TT
> tags are used to include a php script in your template.
  If <A
HREF="variable.security.html"
><TT
CLASS="parameter"
><I
>$security</I
></TT
></A
> is enabled,
  then the php script must be located in the <A
HREF="variable.trusted.dir.html"
><TT
CLASS="parameter"
><I
>$trusted_dir</I
></TT
></A
> path.
  The <TT
CLASS="varname"
>{include_php}</TT
> tag must have the attribute
  <TT
CLASS="parameter"
><I
>file</I
></TT
>, which contains the path to the included php file, either
  relative to  <A
HREF="variable.trusted.dir.html"
><TT
CLASS="parameter"
><I
>$trusted_dir</I
></TT
></A
>,
  or an absolute path.
 </P
><P
>&#13;  By default, php files are only included once even if called
  multiple times in the template. You can specify that it should be
  included every time with the <TT
CLASS="parameter"
><I
>once</I
></TT
> attribute.
  Setting once to <TT
CLASS="constant"
>FALSE</TT
> will include the php script each time it is
  included in the template.
 </P
><P
>&#13;  You can optionally pass the <TT
CLASS="parameter"
><I
>assign</I
></TT
> attribute,
  which will specify a template variable name that the output of
  <TT
CLASS="varname"
>{include_php}</TT
> will be assigned to instead of
  displayed.
 </P
><P
>&#13;  The smarty object is available as <TT
CLASS="parameter"
><I
>$this</I
></TT
> within
  the PHP script that you include.
 </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2134"
></A
><P
><B
>Example 7-21. function {include_php}</B
></P
><P
>The <TT
CLASS="filename"
>load_nav.php</TT
> template.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;load&nbsp;in&nbsp;variables&nbsp;from&nbsp;a&nbsp;mysql&nbsp;db&nbsp;and&nbsp;assign&nbsp;them&nbsp;to&nbsp;the&nbsp;template<br /></span><span style="color: #007700">require_once(</span><span style="color: #DD0000">'MySQL.class.php'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MySQL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$sql</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'select&nbsp;*&nbsp;from&nbsp;site_nav_sections&nbsp;order&nbsp;by&nbsp;name'</span><span style="color: #007700">,</span><span style="color: #0000BB">SQL_ALL</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">'sections'</span><span style="color: #007700">,</span><span style="color: #0000BB">$sql</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">record</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></TD
></TR
></TABLE
><P
>&#13;   Where the teamplate is:
  </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>{* absolute path, or relative to $trusted_dir *}
{include_php file='/path/to/load_nav.php'}

{foreach item='curr_section' from=$sections}
  &#60;a href="{$curr_section.url}"&#62;{$curr_section.name}&#60;/a&#62;&#60;br /&#62;
{/foreach}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;  See also <A
HREF="language.function.include.html"
><TT
CLASS="varname"
>{include}</TT
></A
>,
  <A
HREF="language.function.php.html"
><TT
CLASS="varname"
>{php}</TT
></A
>, <A
HREF="language.builtin.functions.html#language.function.capture"
><TT
CLASS="varname"
>{capture}</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.include.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.insert.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>{include}</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"
>{insert}</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>