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

205 lines
5.8 KiB
XML
Raw Normal View History

2004-03-28 15:15:38 +00:00
<?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>
2004-03-28 15:15:38 +00:00
<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>
2004-03-28 15:15:38 +00:00
<para>
When you encounter a PHP parsing error, the error line number will
2006-09-27 04:32:52 +00:00
correspond to the compiled PHP script, NOT the template itself. Usually
2004-03-28 15:15:38 +00:00
you can look at the template and spot the syntax error. Here are some
common things to look for: missing close tags for
2006-09-27 04:32:52 +00:00
<link linkend="language.function.if"><varname>{if}{/if}</varname></link> or
<link linkend="language.function.if"><varname>{section}{/section}</varname>
</link>, or syntax of logic within an <varname>{if}</varname> tag. If you
2004-03-28 15:15:38 +00:00
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>
2006-09-27 04:32:52 +00:00
<screen>
<![CDATA[
Warning: Smarty error: unable to read resource: "index.tpl" in...
or
Warning: Smarty error: unable to read resource: "site.conf" in...
]]>
2006-09-27 04:32:52 +00:00
</screen>
<para>
<itemizedlist>
<listitem>
<para>
2006-09-27 04:32:52 +00:00
The <link linkend="variable.template.dir">
<parameter>$template_dir</parameter></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>
2006-09-27 04:32:52 +00:00
A <link linkend="language.function.config.load">
<varname>{config_load}</varname></link>
function is within a template (or
2006-09-27 04:32:52 +00:00
<link linkend="api.config.load"><varname>config_load()</varname></link>
has been called) and either
2006-09-27 04:32:52 +00:00
<link linkend="variable.config.dir"><parameter>$config_dir</parameter>
2007-02-27 14:30:20 +00:00
</link> is incorrect, does not exist or
<filename>site.conf</filename> is not in the directory.
</para>
</listitem>
</itemizedlist>
</para>
<screen>
<![CDATA[
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
or is not a directory...
]]>
</screen>
2006-09-27 04:32:52 +00:00
<itemizedlist>
<listitem>
<para>
Either the
2006-09-27 04:32:52 +00:00
<link linkend="variable.compile.dir">
<parameter>$compile_dir</parameter></link>is incorrectly set,
the directory does not exist, or <filename>templates_c</filename> is a
file and not a directory.
</para>
2006-09-27 04:32:52 +00:00
</listitem>
</itemizedlist>
<screen>
<![CDATA[
Fatal error: Smarty error: unable to write to $compile_dir '....
]]>
</screen>
2006-09-27 04:32:52 +00:00
<itemizedlist>
<listitem>
<para>
2006-09-27 04:32:52 +00:00
The <link linkend="variable.compile.dir">
<parameter>$compile_dir</parameter></link> is not writable by the web server.
See the bottom of the
<link linkend="installing.smarty.basic">installing smarty</link> page
2006-09-27 04:32:52 +00:00
for more about permissions.
</para>
2006-09-27 04:32:52 +00:00
</listitem>
</itemizedlist>
<screen>
<![CDATA[
Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
or is not a directory. in /..
]]>
</screen>
2006-09-27 04:32:52 +00:00
<itemizedlist>
<listitem>
<para>
This means that
2006-09-27 04:32:52 +00:00
<link linkend="variable.caching">
<parameter>$caching</parameter></link> is enabled and either;
the
2006-09-27 04:32:52 +00:00
<link linkend="variable.cache.dir"><parameter>$cache_dir</parameter></link>
is incorrectly set, the directory does not exist,
2006-09-27 04:32:52 +00:00
or <filename>cache/</filename> is a
file and not a directory.
</para>
2006-09-27 04:32:52 +00:00
</listitem>
</itemizedlist>
<screen>
<![CDATA[
Fatal error: Smarty error: unable to write to $cache_dir '/...
]]>
</screen>
2006-09-27 04:32:52 +00:00
<itemizedlist>
<listitem>
<para>
This means that
2006-09-27 04:32:52 +00:00
<link linkend="variable.caching"><parameter>$caching</parameter></link> is
enabled and the <link linkend="variable.cache.dir">
<parameter>$cache_dir</parameter></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>,
2006-09-27 04:32:52 +00:00
<link linkend="variable.error.reporting">
<parameter>$error_reporting</parameter></link>
and
2006-09-27 04:32:52 +00:00
<link linkend="api.trigger.error"><varname>trigger_error()</varname></link>.
</para>
2004-03-28 15:15:38 +00:00
</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
2004-03-28 19:15:35 +00:00
-->