Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>display()</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="Smarty Class Methods()"
HREF="api.functions.html"><LINK
REL="PREVIOUS"
TITLE="config_load()"
HREF="api.config.load.html"><LINK
REL="NEXT"
TITLE="fetch()"
HREF="api.fetch.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
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="api.config.load.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="api.fetch.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="api.display"
></A
>display()</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN5752"
></A
>display()&nbsp;--&nbsp;displays the template</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN5755"
></A
><H2
>Description</H2
>void <B
CLASS="methodname"
>display</B
> ( string template [, string cache_id [, string compile_id]])<BR
></BR
><P
>&#13;   This displays the template unlike
   <A
HREF="api.fetch.html"
><TT
CLASS="varname"
>fetch()</TT
></A
>.
   Supply a valid <A
HREF="template.resources.html"
>template resource</A
>
   type and path. As an optional second parameter, you can pass a
   <TT
CLASS="parameter"
><I
>$cache id</I
></TT
>, see the
   <A
HREF="caching.html"
>caching section</A
> for more information.
  </P
><P
>&#13; As an optional third parameter, you can pass a
 <TT
CLASS="parameter"
><I
>$compile_id</I
></TT
>.
 This is in the event that you want to compile different versions of
 the same template, such as having separate templates compiled
 for different languages. Another use for
 <TT
CLASS="parameter"
><I
>$compile_id</I
></TT
> is when you use more than one
 <A
HREF="api.variables.html#variable.template.dir"
><TT
CLASS="parameter"
><I
>$template_dir</I
></TT
></A
>
 but only one
 <A
HREF="variable.compile.dir.html"
><TT
CLASS="parameter"
><I
>$compile_dir</I
></TT
></A
>.
 Set a separate <TT
CLASS="parameter"
><I
>$compile_id</I
></TT
> for each
 <A
HREF="api.variables.html#variable.template.dir"
><TT
CLASS="parameter"
><I
>$template_dir</I
></TT
></A
>,
 otherwise templates of the same name will overwrite each other. You can
 also set the <A
HREF="variable.compile.id.html"
>&#13; <TT
CLASS="parameter"
><I
>$compile_id</I
></TT
></A
> variable once instead of passing
  this to each call to this function.
</P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN5787"
></A
><P
><B
>Example 13-1. display()</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">include(</span><span style="color: #0000BB">SMARTY_DIR</span><span style="color: #007700">.</span><span style="color: #DD0000">'Smarty.class.php'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$smarty&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Smarty</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">caching&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;only&nbsp;do&nbsp;db&nbsp;calls&nbsp;if&nbsp;cache&nbsp;doesn't&nbsp;exist<br /></span><span style="color: #007700">if(!</span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">is_cached</span><span style="color: #007700">(</span><span style="color: #DD0000">'index.tpl'</span><span style="color: #007700">))&nbsp;{<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;dummy&nbsp;up&nbsp;some&nbsp;data<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$address&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"245&nbsp;N&nbsp;50th"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$db_data&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"City"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Lincoln"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"State"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Nebraska"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Zip"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"68502"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;</span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">"Name"</span><span style="color: #007700">,</span><span style="color: #DD0000">"Fred"</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">"Address"</span><span style="color: #007700">,</span><span style="color: #0000BB">$address</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">'data'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$db_data</span><span style="color: #007700">);<br /><br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;display&nbsp;the&nbsp;output<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">(</span><span style="color: #DD0000">'index.tpl'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></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="AEN5790"
></A
><P
><B
>Example 13-2. Other display() template resource examples</B
></P
><P
>&#13;   Use the syntax for <A
HREF="template.resources.html"
>template resources</A
> to
   display files outside of the
   <A
HREF="api.variables.html#variable.template.dir"
>&#13;   <TT
CLASS="parameter"
><I
>$template_dir</I
></TT
></A
> directory.
  </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;absolute&nbsp;filepath<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">(</span><span style="color: #DD0000">'/usr/local/include/templates/header.tpl'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;absolute&nbsp;filepath&nbsp;(same&nbsp;thing)<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">(</span><span style="color: #DD0000">'file:/usr/local/include/templates/header.tpl'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;windows&nbsp;absolute&nbsp;filepath&nbsp;(MUST&nbsp;use&nbsp;"file:"&nbsp;prefix)<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">(</span><span style="color: #DD0000">'file:C:/www/pub/templates/header.tpl'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;include&nbsp;from&nbsp;template&nbsp;resource&nbsp;named&nbsp;"db"<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">(</span><span style="color: #DD0000">'db:header.tpl'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;   See also <A
HREF="api.fetch.html"
><TT
CLASS="varname"
>fetch()</TT
></A
> and
   <A
HREF="api.template.exists.html"
><TT
CLASS="varname"
>template_exists()</TT
></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="api.config.load.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="api.fetch.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>config_load()</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="api.functions.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>fetch()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>