Files
smarty/docs/en/appendixes/troubleshooting.xml

192 lines
5.4 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<chapter id="troubleshooting">
<title>Troubleshooting</title>
<para></para>
<sect1 id="smarty.php.errors">
<title>Smarty/PHP errors</title>
<para>
Smarty can catch many errors such as missing tag attributes
or malformed variable names. If this happens, you will see an error
similar to the following:
</para>
<example>
<title>Smarty errors</title>
<screen>
<![CDATA[
Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah'
in /path/to/smarty/Smarty.class.php on line 1041
Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name
in /path/to/smarty/Smarty.class.php on line 1041
]]>
</screen>
</example>
<para>
Smarty shows you the template name, the line number and the error.
After that, the error consists of the actual line number in the Smarty
class that the error occured.
</para>
<para>
There are certain errors that Smarty cannot catch, such as missing
close tags. These types of errors usually end up in PHP compile-time
parsing errors.
</para>
<example>
<title>PHP parsing errors</title>
<screen>
<![CDATA[
Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
]]>
</screen>
</example>
<para>
When you encounter a PHP parsing error, the error line number will
correspond to the compiled PHP script, not the template itself. Usually
you can look at the template and spot the syntax error. Here are some
common things to look for: missing close tags for
<link linkend="language.function.if">{if}{/if}</link> or
<link linkend="language.function.if">{section}{/section}</link>,
or syntax of logic within an {if} tag. If you
can't find the error, you might have to open the compiled PHP file and
go to the line number to figure out where the corresponding error is in
the template.
</para>
<example>
<title>Other common errors</title>
<itemizedlist>
<listitem>
<screen>
<![CDATA[
Warning: Smarty error: unable to read resource: "index.tpl" in...
or
Warning: Smarty error: unable to read resource: "site.conf" in...
]]>
</screen>
<para>
<itemizedlist>
<listitem>
<para>
The <link linkend="variable.template.dir">$template_dir</link>
is incorrect, doesn't exist or
the file <filename>index.tpl</filename> is not in the
<filename class="directory">templates/</filename> directory
</para>
</listitem>
<listitem>
<para>
A <link linkend="language.function.config.load">{config_load}</link>
function is within a template (or
<link linkend="api.config.load">config_load()</link>
has been called) and either
<link linkend="variable.config.dir">$config_dir</link>
is incorrent , does not exist or
<filename>site.conf</filename> is not in the directory.
</para>
</listitem>
</itemizedlist>
</para>
</listitem><listitem>
<screen>
<![CDATA[
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
or is not a directory...
]]>
</screen>
<para>
Either the
<link linkend="variable.compile.dir">$compile_dir</link>
is incorrectly set, the directory does not exist,
or <filename>templates_c</filename> is a
file and not a directory.
</para>
</listitem><listitem>
<screen>
<![CDATA[
Fatal error: Smarty error: unable to write to $compile_dir '....
]]>
</screen>
<para>
The <link linkend="variable.compile.dir">$compile_dir</link>
is not writable by the web server. See the bottom of the
<link linkend="installing.smarty.basic">installing smarty</link> page
for permissions.
</para>
</listitem><listitem>
<screen>
<![CDATA[
Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
or is not a directory. in /..
]]>
</screen>
<para>
This means that
<link linkend="variable.caching">$caching</link> is enabled and either;
the
<link linkend="variable.cache.dir">$cache_dir</link>
is incorrectly set, the directory does not exist,
or <filename>cache</filename> is a
file and not a directory.
</para>
</listitem><listitem>
<screen>
<![CDATA[
Fatal error: Smarty error: unable to write to $cache_dir '/...
]]>
</screen>
<para>
This means that
<link linkend="variable.caching">$caching</link> is enabled and the
<link linkend="variable.cache.dir">$cache_dir</link>
is not writable by the web server. See the bottom of the
<link linkend="installing.smarty.basic">installing smarty</link> page
for permissions.
</para>
</listitem>
</itemizedlist>
</example>
<para>
See also
<link linkend="chapter.debugging.console">debugging</link>,
<link linkend="variable.error.reporting">$error_reporting</link>
and
<link linkend="api.trigger.error">trigger_error()</link>.
</para>
</sect1>
</chapter>
<!-- 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
-->