Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>Postfilters</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="Advanced Features"
HREF="advanced.features.html"><LINK
REL="PREVIOUS"
TITLE="Prefilters"
HREF="advanced.features.prefilters.html"><LINK
REL="NEXT"
TITLE="Output Filters"
HREF="advanced.features.outputfilters.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="advanced.features.prefilters.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 15. Advanced Features</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="advanced.features.outputfilters.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="advanced.features.postfilters"
></A
>Postfilters</H1
><P
>&#13;  Template postfilters are PHP functions that your templates are ran through
  <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>after they are compiled</I
></SPAN
>. Postfilters can be either
  <A
HREF="api.register.postfilter.html"
>registered</A
> or loaded
  from the <A
HREF="variable.plugins.dir.html"
>plugins directory</A
>
  by using the
  <A
HREF="api.load.filter.html"
><TT
CLASS="varname"
>load_filter()</TT
></A
>
   function or by setting the <A
HREF="variable.autoload.filters.html"
>&#13;   <TT
CLASS="parameter"
><I
>$autoload_filters</I
></TT
></A
> variable.
   Smarty will pass the compiled template code as the first
  argument, and expect the function to return the result of the
  processing.
 </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN6947"
></A
><P
><B
>Example 15-3. Using a template postfilter</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: #FF8000">//&nbsp;put&nbsp;this&nbsp;in&nbsp;your&nbsp;application<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">add_header_comment</span><span style="color: #007700">(</span><span style="color: #0000BB">$tpl_source</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$smarty</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #DD0000">"&lt;?php&nbsp;echo&nbsp;\"&lt;!--&nbsp;Created&nbsp;by&nbsp;Smarty!&nbsp;--&gt;\n\";&nbsp;?&gt;\n"</span><span style="color: #007700">.</span><span style="color: #0000BB">$tpl_source</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;register&nbsp;the&nbsp;postfilter<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">register_postfilter</span><span style="color: #007700">(</span><span style="color: #DD0000">'add_header_comment'</span><span style="color: #007700">);<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
><P
>&#13;   The postfilter above will make the compiled Smarty template
   <TT
CLASS="filename"
>index.tpl</TT
> look like:
  </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>&#60;!-- Created by Smarty! --&#62;
{* rest of template content... *}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13; See also
 <A
HREF="api.register.postfilter.html"
><TT
CLASS="varname"
>register_postfilter()</TT
></A
>,
 <A
HREF="advanced.features.prefilters.html"
>prefilters</A
>
 and
 <A
HREF="api.load.filter.html"
><TT
CLASS="varname"
>load_filter()</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="advanced.features.prefilters.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="advanced.features.outputfilters.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Prefilters</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="advanced.features.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Output Filters</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>