Get Smarty

Donate

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

Advertisement

Chapter 17. トラブルシューティング

Table of Contents

Smarty/PHP エラー

Smarty/PHP エラー

Smarty は、タグの属性が不足していたり、誤った変数名を指定していた時など、 多くのエラーをキャッチする事ができます。 キャッチすると次の例のようなエラーが表示されます。

Example 17.1. Smarty エラー


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 はテンプレート名・エラー行番号・エラー内容を示します。 その次のエラーは、Smarty クラスにおいてエラーが発生した実際の行番号から成るメッセージです。

タグの閉じ忘れのような、Smarty がキャッチできないエラーがあります。 通常、このような場合のエラーは PHP コンパイル時にパースエラーで終了します。

Example 17.2. PHP パースエラー


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

    

PHP パースエラーの場合のエラー行番号は、 テンプレートそのものではなくコンパイルされた PHP スクリプトに一致します。 通常、テンプレートを見ることで構文エラーを見つけられます。 一般的な間違いとしては、 {if}{/if}{section}{/section} タグの閉じ忘れ、{if} タグ内のロジックの構文の誤りなどがあります。もしエラーが見つけられない場合は、 テンプレートのどこに該当するエラーがあるかを見い出すために、 コンパイルされた PHP ファイルを開いて行番号のあたりを調べる必要があります。

Example 17.3. その他共通のエラー


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

  • $template_dir が存在しない不正なディレクトリか、もしくは存在しても index.tpltemplates/ ディレクトリ内にありません。

  • {config_load} 関数がテンプレート内にあり (もしくは config_load() で呼び出されており)、その際の $config_dir が存在しない不正なディレクトリか、もしくは存在しても site.conf がそのディレクトリ内にありません。


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

    
  • $compile_dir に不正な値が入っており、そのようなディレクトリが存在しないか、もしくは templates_c の指定がディレクトリではなくファイルです。


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

    
  • $caching が有効であるにも関わらず、 $cache_dir が存在しない不正なディレクトリか、もしくは存在しても cache/ がディレクトリではなくファイルである、という意味です。


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

    
  • $caching が有効であるにも関わらず、 $cache_dir に Web サーバによる書き込み権限がない、という意味です。 Smarty のインストール のページ下部のパーミッションの項を参照してください。


デバッギング も参照ください。

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors