Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>template_exists()</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="trigger_error()"
HREF="api.trigger.error.html"><LINK
REL="NEXT"
TITLE="unregister_block()"
HREF="api.unregister.block.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.trigger.error.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="api.unregister.block.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="api.template.exists"
></A
>template_exists()</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN6471"
></A
>template_exists()&nbsp;--&nbsp;checks whether the specified template exists</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN6474"
></A
><H2
>Description</H2
>bool <B
CLASS="methodname"
>template_exists</B
> ( string template)<BR
></BR
><P
>&#13;   It can  accept either a path to the template on the filesystem or a
   resource string specifying the template.
  </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN6483"
></A
><P
><B
>Example 13-1. template_exists()</B
></P
><P
>&#13;    This example uses <TT
CLASS="literal"
>$_GET['page']</TT
> to
    <A
HREF="language.function.include.html"
><TT
CLASS="varname"
>{include}</TT
></A
>
    a content template. If the template does not exist then an error page
    is displayed instead. First the <TT
CLASS="filename"
>page_container.tpl</TT
>
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><span style="color: #000000">
&lt;html&gt;<br />&lt;head&gt;&lt;title&gt;{$title}&lt;/title&gt;&lt;/head&gt;<br />&lt;body&gt;<br />{include&nbsp;file='page_top.tpl'}<br /><br />{*&nbsp;include&nbsp;middle&nbsp;content&nbsp;page&nbsp;*}<br />{include&nbsp;file=$content_template}<br /><br />{include&nbsp;file='page_footer.tpl'}<br />&lt;/body&gt;</span>
</code></TD
></TR
></TABLE
><P
>&#13;  And the php script
  </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;set&nbsp;the&nbsp;filename&nbsp;eg&nbsp;index.inc.tpl<br /></span><span style="color: #0000BB">$mid_template&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'page'</span><span style="color: #007700">].</span><span style="color: #DD0000">'.inc.tpl'</span><span style="color: #007700">;<br /><br />if(&nbsp;!</span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$mid_template</span><span style="color: #007700">)&nbsp;){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$mid_template&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'page_not_found.tpl'</span><span style="color: #007700">;<br />}<br /></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">'content_template'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$mid_template</span><span style="color: #007700">);<br /><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">'page_container.tpl'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;  See also
  <A
HREF="api.display.html"
><TT
CLASS="varname"
>display()</TT
></A
>,
  <A
HREF="api.fetch.html"
><TT
CLASS="varname"
>fetch()</TT
></A
>,
  <A
HREF="language.function.include.html"
><TT
CLASS="varname"
>{include}</TT
></A
>
  and
  <A
HREF="language.function.insert.html"
><TT
CLASS="varname"
>{insert}</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.trigger.error.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.unregister.block.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>trigger_error()</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"
>unregister_block()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>