2004-04-13 11:47:32 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
<!-- $Revision$ -->
|
2004-04-18 19:22:55 +00:00
|
|
|
<refentry id="api.template.exists">
|
|
|
|
<refnamediv>
|
2005-05-27 16:25:02 +00:00
|
|
|
<refname>template_exists()</refname>
|
|
|
|
<refpurpose>checks whether the specified template exists</refpurpose>
|
2004-04-18 19:22:55 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
2005-05-27 16:25:02 +00:00
|
|
|
<title>Description</title>
|
2004-04-18 19:22:55 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>bool</type><methodname>template_exists</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2005-05-27 16:25:02 +00:00
|
|
|
It can accept either a path to the template on the filesystem or a
|
2004-04-18 19:22:55 +00:00
|
|
|
resource string specifying the template.
|
|
|
|
</para>
|
2005-06-05 15:47:25 +00:00
|
|
|
|
|
|
|
<example>
|
|
|
|
<title>template_exists()</title>
|
|
|
|
<para>
|
2006-09-26 23:29:02 +00:00
|
|
|
This example uses <literal>$_GET['page']</literal> to
|
|
|
|
<link linkend="language.function.include"><varname>{include}</varname></link>
|
|
|
|
a content template. If the template does not exist then an error page
|
|
|
|
is displayed instead. First the <filename>page_container.tpl</filename>
|
2005-06-05 15:47:25 +00:00
|
|
|
</para>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<html>
|
|
|
|
<head><title>{$title}</title></head>
|
|
|
|
<body>
|
|
|
|
{include file='page_top.tpl'}
|
|
|
|
|
|
|
|
{* include middle content page *}
|
2006-09-26 23:29:02 +00:00
|
|
|
{include file=$content_template}
|
2005-06-05 15:47:25 +00:00
|
|
|
|
|
|
|
{include file='page_footer.tpl'}
|
|
|
|
</body>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
2006-09-26 23:29:02 +00:00
|
|
|
And the php script
|
2005-06-05 15:47:25 +00:00
|
|
|
</para>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// set the filename eg index.inc.tpl
|
2005-06-05 18:22:56 +00:00
|
|
|
$mid_template = $_GET['page'].'.inc.tpl';
|
2005-06-05 15:47:25 +00:00
|
|
|
|
2005-06-05 18:21:34 +00:00
|
|
|
if( !$smarty->template_exists($mid_template) ){
|
2006-09-26 23:29:02 +00:00
|
|
|
$mid_template = 'page_not_found.tpl';
|
2005-06-05 17:56:39 +00:00
|
|
|
}
|
2006-09-26 23:29:02 +00:00
|
|
|
$smarty->assign('content_template', $mid_template);
|
2005-06-05 15:47:25 +00:00
|
|
|
|
|
|
|
$smarty->display('page_container.tpl');
|
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
|
2005-05-24 14:01:49 +00:00
|
|
|
<para>
|
|
|
|
See also
|
2006-09-26 23:29:02 +00:00
|
|
|
<link linkend="api.display"><varname>display()</varname></link>,
|
|
|
|
<link linkend="api.fetch"><varname>fetch()</varname></link>,
|
|
|
|
<link linkend="language.function.include"><varname>{include}</varname></link>
|
2005-05-24 14:01:49 +00:00
|
|
|
and
|
2006-09-26 23:29:02 +00:00
|
|
|
<link linkend="language.function.insert"><varname>{insert}</varname></link>
|
2005-05-24 14:01:49 +00:00
|
|
|
</para>
|
2004-04-18 19:22:55 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2004-04-13 11:47:32 +00:00
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
2004-04-18 19:22:55 +00:00
|
|
|
-->
|