Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Largest classified with thousands of ads at Shoppok

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy wedding dresses on SiteSteer.com - Best Online Wedding Dress Store

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Find Wedding Dresses Online at Canada from Ca-dresses.com

Chapter 20. Troubleshooting

Table of Contents

Smarty/PHP errors

Smarty/PHP errors

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:

Example 20.1. Smarty errors


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

    

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 occurred.

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.

Example 20.2. PHP parsing errors


Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75

    

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 {if}{/if} or {section}{/section} , 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.

Example 20.3. Other common errors


Warning: Smarty error: unable to read resource: "index.tpl" in...
or
Warning: Smarty error: unable to read resource: "site.conf" in...

  • The $template_dir is incorrect, doesn't exist or the file index.tpl is not in the templates/ directory

  • A {config_load} function is within a template (or configLoad() has been called) and either $config_dir is incorrect, does not exist or site.conf is not in the directory.


Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
or is not a directory...

    
  • Either the $compile_diris incorrectly set, the directory does not exist, or templates_c is a file and not a directory.


Fatal error: Smarty error: unable to write to $compile_dir '....

    

Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
or is not a directory. in /..

    
  • This means that $caching is enabled and either; the $cache_dir is incorrectly set, the directory does not exist, or cache/ is a file and not a directory.


Fatal error: Smarty error: unable to write to $cache_dir '/...

    

Warning: filemtime(): stat failed for /path/to/smarty/cache/3ab50a623e65185c49bf17c63c90cc56070ea85c.one.tpl.php 
in /path/to/smarty/libs/sysplugins/smarty_resource.php

   
  • This means that your application registered a custom error hander (using set_error_handler()) which is not respecting the given $errno as it should. If, for whatever reason, this is the desired behaviour of your custom error handler, please call muteExpectedErrors() after you've registered your custom error handler.


See also debugging.

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 15 plus 8? (Are you human?)

Sponsors [info]

UK Web Hosting @webhost.uk.net
Best Web Hosting @rshosting.com
Web Hosting UK @webhostinguk.com
Unlimited Web Hosting @infrenion.com
App Entwicklung @morphodo.com
Buy from China @dhgate.com
First Click Internet Marketing @fcinternetmarketing.com