さくらでのSmarty設置
さくらでのSmarty設置ですが、 まず、公式サイト(http://www.smarty.net/)から、Smarty本体をDL。
解凍します。
解凍したものの中に、libsフォルダがあるので、それをさくらのサーバーにアップする。 さくらのサーバーの公開ディレクトリまでのパス構造は、 /home/アカウント名/www になっているが、公開ディレクトリより上層のディレクトリにも設置可能な為、 /home/アカウント名/ に、上記libsフォルダをアップロード。
templatesディレクトリ&templates_cディレクトリも、公開ディレクトリより上層へ設置したかった為、 MySmarty.class.phpを作成。内容は↓
<?php
define ("ROOT_DIR" ,$_SERVER['DOCUMENT_ROOT']."/..");
require_once("Smarty.class.php");
class MySmarty extends Smarty {
function MySmarty () {
$this->template_dir = ROOT_DIR."/templates";
$this->compile_dir = ROOT_DIR."/templates_c";
$this->left_delimiter = "<{";
$this->right_delimiter = "}>";
$this->Smarty();
}
}
?>
デリミタも、<{}>に変更してます。 libs内へアップロード。
phpでの呼び出し時は、
require_once ("../libs/MySmarty.class.php" );
で、いけました。
- tag
- php
- smarty
- さくらインターネット
- 設定