• 締切済み

Smartyのエラーが2つずつ出ます

PHP5+Smartyでサイトを作っています。 「$smarty->display("hoge.tpl");」としてテンプレートファイルを呼び出します。 そのテンプレートファイル「hoge.tpl」が存在しない時に、以下のエラー文が必ず2つ表示されます。 Warning: Smarty error: unable to read resource: "hoge.tpl" in /root/.../smarty/Smarty.class.php on line 1092 一度しか呼び出していないのにエラーが2つ表示されるので、コードの記述ミスかと考えたのですがわかりませんでした。 テンプレートファイルがある場合は、テンプレートが二度呼び出されることはありません。 エラー文にある1092行目からコードを追って見たのですがわかりませんでした。 どうすればエラー表示を1つにできるのでしょうか? 宜しくお願いします。

  • PHP
  • 回答数1
  • ありがとう数1

みんなの回答

  • tany180sx
  • ベストアンサー率63% (239/379)
回答No.1

普通に考えるとそのline:1092を2回通っているんでしょう。 versionも分からないし、ソースまでは見ませんが 気になるなら debug_print_backtrace() でもしてみては?

参考URL:
http://phpspot.net/php/man/php/function.debug-print-backtrace.html
ka-kichi
質問者

お礼

ご回答ありがとうございました。 バージョンは、PHPが5.?。Smartyが2.6.22です。 debug_print_backtrace()では何も表示されませんでした。 使い方が間違っていたのかも…(ーー;) 自分で書いたソースを見る限り、一度しか呼び出していないはずなので、何をお伝えすれば解決につながるのか…がわかりません。(^^ゞ 現状で、テンプレートファイルが存在すれば不都合はないので、しばらく様子を見てみます。

関連するQ&A

  • ロリポップでSmartyのtpl読み込みエラー

    下記のコードを実行すると、  Smarty error: unable to read resource: "template1.tpl"  というエラーが出てしまいます。 $smarty->template_dirで指定したディレクトリ名の中に  "template1.tpl"というファイルは配置してあります。  原因などわかればおしえていただけないでしょうか。 index.php <?php require_once("Smarty.class.php"); $smarty = new Smarty; $smarty->template_dir = './templates/'; $smarty->compile_dir = './templates_c/'; $smarty->config_dir = './configs/'; $smarty->cache_dir = './cache/'; $smarty->display("template1.tpl"); ?> 【サーバ】  ロリポップです。 【その他】 index.phpをホームディレクトリ配下におくとエラーは消えます。 【ディレクトリ構成】 modules/index.php と templates/template1.tpl をがあり、 index.php から template1.tpl を読み込もうとしています。  ・modules →index.php ・templates →template1.tpl

    • ベストアンサー
    • PHP
  • Smartyでテンプレートが読み込めない

    下記のソースを実行すると、テンプレートが読み込めずエラーになってしまいます。 うーん、何故なのか分からず困っております。 phpのバージョンは4.4.6なのですが、Ver5以降でないとサポートされないのでしょうか。 [source] <?php require_once("Smarty.class.php"); class MySmarty extends Smarty { function _MySmarty() { $this->Smarty(); $this->template_dir="../templates"; $this->compile_dir="../templates_c"; } } $o_smarty=new MySmarty(); $o_smarty->display("hello.tpl"); ?> [error message] Warning: Smarty error: unable to read resource: "hello.tpl"

    • ベストアンサー
    • PHP
  • Smarty includeでテンプレートを読み込めない

    よろしくお願いします。 まずphpファイルから $smarty->display('111/body.tpl');(*111はディレクトリ名) を呼び出して、さらにbody.tplと同ディレクトリにあるcontents.tplを読み込もうとしています。 はじめのbody.tplは読み込むことができブラウザで表示されるのですが、contents.tplは読み込めず、 Warning: Smarty error: unable to read resource: "contents.tpl" in <絶対パス>/Smarty/Smarty.class.php on line 1095 のエラーが出てしまいます。 ちなみに/111/というディレクトリは、$template_dir以下、$template_dir/111/です。 {include file="contents.tpl"} {include file="file:contents.tpl"} {include file="絶対パス/contents.tpl"} {include file="file:絶対パス/contents.tpl"} など試しましたが、ダメでした。 知恵をお貸しください。よろしくお願いします。

    • ベストアンサー
    • PHP
  • smartyテンプレート読み込みについて

    Smarty動的Webサイト構築入門という書籍を見ながらSmartyを学習しているのですが、書籍のCD-ROMから落としたサンプルファイルを保存しているのですがどうしてもテンプレートを読み込むことができません。 03_01.php <?php require_once("../smarty/libs/Smarty.class.php"); $smarty = new Smarty(); $smarty->template_dir = "templates"; $smarty->compile_dir = "templates_c"; $smarty->assign("name", "Smartyさん"); $smarty->display("03_01.tpl"); ?> 03_01.tpl Hello, {$name}!! エラーメッセージ Warning: Smarty error: unable to read resource: "03_01.tpl" in C:\xampp\htdocs\smartybook\smarty\libs\Smarty.class.php on line 1092 03_01.phpは、C:\xampp/htdocs/smartybook/ren/に保存しています。 03_01.tplは、C:\xampp/htdocs/smartybook/templates/に保存しています。 どこが駄目なのか教えてください。 宜しくお願いします。

    • 締切済み
    • PHP
  • Smartyエラーについて

    いつもお世話になっております。 Smartyのエラーが解決できなくて困っています。 お手数ですが、後教授願えないでしょうか。 使用環境:Ubuntu Eclipse [エラー] Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list.tpl'' in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php:163 Stack trace: #0 /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php(550): Smarty_Internal_Template->isExisting(true) #1 /home/mobapendev/public_html/Smarty/Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #2 /home/mobapendev/public_html/Smarty/Smarty.class.php(382): Smarty->fetch('list.tpl', NULL, NULL, NULL, true) #3 /home/mobapendev/public_html/mobapen/list.php(20): Smarty->display('list.tpl') #4 {main} thrown in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php on line 163 ディレクトリ構成 Smarty/Smarty.class.php Project/list.php Project/php/common.php project/smarty/templates/list.tpl project/smarty/templates_c project/smarty/cache project/smarty/configs となっており、 common.phpにて、 $dir = getcwd(); $smarty->template_dir=$dir .'/smarty/templates'; $smarty->compile_dir=$dir .'/smarty/templates_c'; $smarty->config_dir=$dir .'/smarty/configs'; $smarty->cache_dir =$dir .'/smarty/cache'; list.phpにて require_onceで取り込みまいしたが、 $smarty->display("list.tpl"); ディレクトリは間違っていないとは思っているのですが、 どこでload出来てていなか分からず、攻め上げいている状況です。 以上、宜しくお願い致します。

    • ベストアンサー
    • PHP
  • zendにsmarty3の組込で

    こちらのページを参考に表示にsmartyを入れてみました。 http://www.phppro.jp/school/smarty/vol12/2 ※smartyは3.0.6でzendは1.11.3です indexActionで格納した変数はtplで表示されているので組込は 成功しているかと思うのですが下記のようなエラーが表示されます。 Warning: include_once(Smarty\Internal\Data.php) Warning: include_once(Smarty\Internal\Template.php) ファイルを確認すると確かに該当データがありません。 smarty3なのでフォルダ名がInternalではなくsyspluginsに変わって いる事が原因かと思うのですがどのように対処すればいいでしょうか?

    • ベストアンサー
    • PHP
  • Smartyのエラーについて

    お世話になります。 Windows2003でSmartyを使用しています。 Smartyの設定を終えて、index.phpを開くと下記の ようなエラーが出てしまいます。 Warning: Failed opening 'templates_c\%%45^45E^45E480CD%%index.tpl.php' for inclusion (include_path='D:/include') in D:\include\Smarty.class.php on line 1258 Warning: Failed opening 'templates_c\%%D2^D20^D20FCB1F%%debug.tpl.php' for inclusion (include_path='D:/include') in D:\include\Smarty.class.php on line 1925 実際にtemplates_cフォルダを見てみると正常にファイルができています。 よろしくお願いいたします

    • 締切済み
    • PHP
  • smartyについて

    smartyにでサイトを作る際のテンプレート構造について質問です。 現在はindex.phpで $smarty->display('hoge.tpl'); としhoge.tplは {include file="./common/header.tpl"} <div id="contents"> {include file="./common/left_side.tpl"} <div id="center"> ここに表示する内容 </div> {include file="./common/right_side.tpl"} </div> {include file="./common/footer.tpl"} のようにしています。 表示する内容はそれぞれ違うものの全てではありませんがincludeする tplは他のページもほぼ同様ですのでもっと効率的にできるのでは?と 思うのですがどんな方法があるでしょうか?

    • 締切済み
    • PHP
  • SMARTYのエラーについて。について。

    今度業務でPHPをやる事になったので手始めにSmartyを使って簡単なアプリケーションを作ってみようと思ったのですが、最初の段階でいきなりつまづいてしましました。 具体的には、サンプルサイトからコピーした以下の様なphp&テンプレートを動かすと決まって次のエラーになります。 【/var/www/html/test/index.php】 <?php require_once('/var/www/smarty/libs/Smarty.class.php'); $smarty = new Smarty; $smarty->assign('name', 'test'); $smarty->display('index.tpl'); ?> 【/var/www/html/test/templates/index.tpl】 <html> <head> <title>User Info</title> </head> <body> 名前:{$name}<br> </body> 【エラー】 Warning: preg_match() [function.preg-match]: Compilation failed: repeated subpattern is too long at offset 18454 in /var/www/smarty/libs/Smarty_Compiler.class.php on line 454 ちなみに環境は以下の通りです。 OS:CentOS5.2 web:apache2.2.3 php:5.1.6 Smarty:2.6.21 同様の基本的なサンプルを他にもいくつか実行しましたが、結果は上記エラーと全く同一のものしか出力されません… 同じ症状が出て対応された方がいらっしゃいましたら回答の程よろしくお願い致します。

    • ベストアンサー
    • PHP
  • smartyについて

    smartyについて 環境は、windows /php-5 / smarty-2.6.17です。 以下の2つエラーが出てどう対処すればいいか困っています。 【1つめ】 Fatal error: Smarty error: [in **.tpl line 10]: syntax error: unrecognized tag: 文--> 【2つめ】 {$errmsg (Smarty_Compiler.class.php, line 446) in C:\xampp\php\PEAR\Smarty\libs\Smarty.class.php on line 1095 【ソース】 呼び先PGは、 $this->smarty->assign("errmsg","ニックネーム"); $this->smarty->display("**.tpl"); テンプレートでは、 <tr id="" class=""> <td id="" class=""><font color="#ff0000">{$errmsg}を入力してください。</font></td> </tr> よろしくお願いいたします。

    • 締切済み
    • PHP

専門家に質問してみよう