• 締切済み

共通テンプレートを呼ぶ

src/common/header.tplを src/hoge/hoge.tplから {include file="../common/header.tpl"} として呼びだしたい。 エラーメッセージが Warning: Smarty error: (secure mode) accessing "../common/header.tpl" is not allowed in C:\php\libs\Smarty.class.php on line 1088 です。 #### 設定 php.ini include_path = ".;C:\php\libs;C:\php\PEAR" safe_mode = Off Smarty.class.php $smarty->template_dir="."; {include file}を絶対パスで記述しても同じエラーです。 おそらくこのsecure modeの設定が正しく設定されていないのでしょうが その設定方法がいまいちよくわかりません。 簡単なことなのかもしれませんが、ご存知の方がいらっしゃいましたら ご教授願えないでしょうか。 よろしくお願いいたします。 環境 Windows XP php-5.0.5 Smarty-2.6.10

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

みんなの回答

回答No.1

Smarty.class.phpの1088行目の設定を見直してみればよろしいかと思います。

bakenshibakenshi
質問者

お礼

Intel_404さん、ご回答有難うございます。 1088行目のtrigger_errorですよね。 $error_typeを変えるぐらいしかわからないのですが・・・。 しかしこの実装は何とかできました。 有難うございました。

関連するQ&A

  • 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 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のテンプレートにincludeしたファイルを表示したいので

    Smartyのテンプレートにincludeしたファイルを表示したいのですが、うまくいきません。 具体的には、意図しない数値が入ってしまいます。 どうすればよいのでしょうか? ■呼び出す側 require("../../libs/Smarty.class.php"); require_once('../../lib/set_include_path.php'); $header = include("header.php"); $smarty = new Smarty(); $smarty->assign("header",$header); $smarty->display("date.html"); ■テンプレート <body> {$header}<br>日付<br> ■表示例 include("header.php"); の内容が正常表示 1 日付 include("header.php"); の内容が正常表示された後、勝手に「1」と表示されるので、困ってます。表示されないようにするにはどうすればよいでしょうか。 var_dump($header);ってしたところ、int(1) ってなるので、この1が表示されているのかと思うのですが、なんで表示されるのか、表示されないようにするにはどうすればよいか、教えてください。

    • ベストアンサー
    • 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
  • tplを読みに行けません。

    PHP+smartyを学んでいます。 Apache2-htdocs-taro-hanako.php とファイルを置き、一方、 Apache2-php_libs-smarty の下に -libs/ (中にSmarty.class.php あり) と -templates/ (中にtest.tpl あり)を並列的におきました。 hanako.php に、 require_once "../../php_libs/smarty/libs/Smarty.class.php"; $smarty = new Smarty; $smarty->templete_dir = "../../php_libs/smarty/templates";   $smarty->compile_dir = "../../php_libs/smarty/templates_c"; $smarty->cache_dir = "../../php_libs/smarty/cache"; 以下省略・・・ と書いてブラウザで開くと、次のエラーが出て、tpl を読み込むことが出来ません。 Warning: Smarty error: unable to read resource: "test.tpl" in C:\Program Files\Apache Group\Apache2\php_libs\smarty\libs\Smarty.class.php on line 1088 どこを間違えているのでしょうか。

    • ベストアンサー
    • 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のdifineについて

    表示するファイルにdefineにてパスを設定すると正常に 表示されるのですが管理が面倒なので別のファイルに defineにてパスを設定するとエラーになってしまいます。 具体的には以下のソースです。 ---Smarty/libs/path.php--- define ('SMARTY_LIBS_DIR', 'C:/Program Files/xampp/htdocs/Smarty/libs/'); ---Smarty/libs/MySmarty.class.php--- require_once dirname(__FILE__) . '/Smarty.class.php'; require_once dirname(__FILE__) . '/path.php'; ---Smarty/index.php--- require_once SMARTY_LIBS_DIR . 'MySmarty.class.php'; 調べてみたのですが表示するファイルに指定する方法しか みつからなかったのですが別ファイルから指定する事は 無理なのでしょうか?

    • 締切済み
    • 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をセットアップする

    http://www.mogutan-blog.com/?eid=283 さくらサーバーと格闘しています。 上記ブログやその他ブログを見ながらパスは通りましたが、やりたい方法とちがうので改めてこちらでお聞きします。 私の方法 1.smartyをwww以下にアップ 2.アップしたフォルダをlibsと改名 3.index.phpでrequire_once '../libs/smarty/Smarty.class.php'; としてokでした。 しかし、php.iniを使って、 require_once './Smarty.class.php'; とパスを編集するには、php.iniをどのように書けばよろしいでしょうか? 現在は、include_path=".:/home/アカウント名/libs/" としており、どのように書けばパスが通るでしょうか? ちなみに簡略フォルダー展開ですが、 ルート ├ libs(smarty)- Smarty - Smarty.class.php ├ php.ini ├ www ┬ index.php     

    • ベストアンサー
    • PHP
  • smartyの設定 include?path以下の設定がわからない

    独学でPHPを学んでいます。 PHPの基本はひととおり理解はできました。 開発環境・最新のXAMPP導入。 windows、OSはVISTA smartyをインストールしましたが、その設定につまずいています。 Smarty.class.phpが存在するパス(D:\xampp\libs)をphp.iniファイル447行目を下記のように設定しましたが、うまくいきません include_path=D:\xampp\libs\ xamppフォルダの下にlibsフォルダを入れたので上のパス指定で問題ないと思うのですが、どこが間違っているのでしょうか。 ちなみに、libs以下の\も不要だろうと思い、消したりして試してみましたが、結果は同じ。下記のように表示がなされます。 Warning: require_once(local/xampp/libs/Smarty.class.php) [function.require-once]: failed to open stream: No such file or directory in D:\xampp\htdocs\lesson\smarty1.php on line 3 Fatal error: require_once() [function.require]: Failed opening required 'local/xampp/libs/Smarty.class.php' (include_path='.;D:\xampp\php\pear\') in D:\xampp\htdocs\lesson\smarty1.php on line 3 上の文章ですが、3行目後半”Smarty.class.php' (include_path='.;D:\xampp\php\pear\')”の部分ですが、php.iniからinclude_pathを変更したりしているのですが、一向に表示が変わりません。 もしかしたらphp.iniファイルは二つあったりするのでしょうか。 php.iniのファイルはPHPフォルダに入っているものでよろしいですよね? もちろんアパッチは再起動させています。 なのにできません・ あと、ロジックファイルの require _once()の()内はSmarty.class.phpだけでもよろしいのでしょうか。 もう悩みすぎて頭がおかしくなりそうですね。 ちなみにsmartyがなくても、アプリケーション開発に支障はありませんでしょうか。 あくまで個人で趣味の範囲でアプリケーションを作成したいと感じています。

    • ベストアンサー
    • PHP

専門家に質問してみよう