「Php/Smarty/smarty5」の版間の差分

提供: 初心者エンジニアの簡易メモ
ナビゲーションに移動 検索に移動
編集の要約なし
4行目: 4行目:
==smarty4から5へ==
==smarty4から5へ==
===setterへ===
===setterへ===
$smarty->cache_dir、$smarty->template_dir、$smarty->compile_dir への設定をそれぞれ変更。
修正前
 
<pre>
$smarty->cache_dir = '/path/to/cache';
$smarty->template_dir = '/path/to/templates';
$smarty->compile_dir = '/path/to/templates_c';
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
</pre>
修正後
<pre>
<pre>
$this->setCacheDir('/path/to/cache');
$smarty->setCacheDir('/path/to/cache');
$this->setTemplateDir('/path/to/templates');
$smarty->setTemplateDir('/path/to/templates');
$this->setCompileDir('/path/to/templates_c');
$smarty->setCompileDir('/path/to/templates_c');
$smarty->setLeftDelimiter('{{'');
$smarty->setRightDelimiter('}}'');
</pre>
</pre>


===getterへ===
===getterへ===
修正前
<pre>
$smarty->template_dir;
$smarty->compile_dir;
$smarty->cache_dir;
$smarty->left_delimiter;
$smarty->right_delimiter;
</pre>
修正後
<pre>
<pre>
$smarty->template_dir; $smarty->getTemplateDir();
$smarty->getTemplateDir();
$smarty->compile_dir を $smarty->getCompileDir();
$smarty->getCompileDir();
$smarty->cache_dir を $smarty->getCacheDir();
$smarty->getCacheDir();
$smarty->getLeftDelimiter();
$smarty->getRightDelimiter();
</pre>
</pre>



2026年4月4日 (土) 22:07時点における版

smarty5のダウンロード

https://github.com/smarty-php/smarty/releases/tag/v5.8.0

smarty4から5へ

setterへ

修正前

$smarty->cache_dir = '/path/to/cache';
$smarty->template_dir = '/path/to/templates';
$smarty->compile_dir = '/path/to/templates_c';
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';

修正後

$smarty->setCacheDir('/path/to/cache');
$smarty->setTemplateDir('/path/to/templates');
$smarty->setCompileDir('/path/to/templates_c');
$smarty->setLeftDelimiter('{{'');
$smarty->setRightDelimiter('}}'');

getterへ

修正前

$smarty->template_dir;
$smarty->compile_dir;
$smarty->cache_dir;
$smarty->left_delimiter;
$smarty->right_delimiter;

修正後

$smarty->getTemplateDir();
$smarty->getCompileDir();
$smarty->getCacheDir();
$smarty->getLeftDelimiter();
$smarty->getRightDelimiter();

use必須

new Smartyなどで、Smartyを使ってる箇所に以下を追加

use Smarty\Smarty;