2006-06-02 (金)
■ Ethna のテンプレートエンジンに Simplate を使う
Ethna のテンプレートエンジンに、 Simplate を使えないか試してみる。
Ethna.php の以下の行をコメントアウト。
include_once('Smarty/Smarty.class.php');
class/Ethna_Controller.php の $smarty =& new Smarty(); の部分を 以下のように変更。
$smarty =& new simplate();
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
これだけだと、 Smarty で使えて Simplate で使えない関数の部分でエラーが出るので、 さらに以下の箇所を修正。
- class/Ethna_Controller.php の中で、register_modifier(), register_function(), register_block() を呼んでいる箇所を全てコメントアウト
- class/Ethna_ViewClass.php の中で、assign_by_ref() を呼んでいる箇所を全て assign() に変更
これで、デフォルトの index.php は表示できた。
次に、Ethna のチュートリアルのサンプルを、 テンプレートを修正して動くようにしてみる。
まず、以下の箇所がひっかかる。
{foreach from=$errors item=error}
<li>{$error}</li>
{/foreach}
Simplate では foreach 文は使えないようなので、 代わりに section 文を使って以下のように書く。
{section name=i loop=$errors}
<li>{$errors[i]}</li>
{/section}
次に、以下の箇所でひっかかる。
{message name="password"}
こういう Smarty 関数の呼び出しは Simplate ではできないので、 とりあえずこの部分は削除する。
以上の修正で、チュートリアルのサンプルも動かすことができた。
■ Ethna のテンプレートエンジンに Simplate を使う (2)
{message name="password"} と Smarty 関数を使っているところを、 PHP の関数の直接呼び出しにしたら動くんじゃないかと思い、 以下のように書き換えてみた、
{smarty_function_message('password')}
ところが、以下のようなエラーが出る。
Sample[747](WARNING): global.smarty_function_message(/tmp/login.tpl:17): [PHP] E_WARNING: Missing argument 2 for smarty_function_message(), called in /home/revulo/Ethna/sample/tmp/login.tpl on line 17 and defined in /usr/share/php/Ethna/class/Ethna_SmartyPlugin.php on line 417 Sample[747](WARNING): global.extract(class/Ethna_SmartyPlugin.php:421): [PHP] E_WARNING: extract() [function.extract]: First argument should be an array in /usr/share/php/Ethna/class/Ethna_SmartyPlugin.php on line 421
なに? 配列をよこせだと? おまけにもう1つ引数が必要?? どういう関数になっているのか見てみる。
function smarty_function_message($params, &$smarty)
{
$c =& Ethna_Controller::getInstance();
extract($params);
$action_error =& $c->getActionError();
print htmlspecialchars($action_error->getMessage($name));
}
ということは、 array('name' => 'password') みたいな連想配列を引数に取るということか? あと、2番目の引数が必須になっているが、その割に使われていない。 これは、内部で smarty_function_message() を呼び出すような 別の関数を作らないとダメかな。
- 3 google検索(ethna missing)
- 3 google検索(Ethna foreach)
- 3 google検索(smarty ethna 関数)
- 3 google検索(ethna 連想配列 テンプレート)
- 3 http://www.google.co.jp/hws/search?hl=ja&q=ZEND sm...
- 3 http://cache.yahoofs.jp/search/cache?p=php pear "F...
- 2 google検索(Ethna テンプレートエンジン)
- 2 google検索(Ethna_SmartyPlugin.php)
- 2 google検索(simplate 連想配列)
- 2 google検索(smarty Templateエンジン サンプル)
- 2 google検索(C テンプレートエンジン)
- 2 google検索(Ethna Smarty テンプレート if関数)
- 2 google検索(section first simplate)
- 2 google検索(php ethna smarty foreach)
- 2 google検索(ethna smarty foreach)
- 2 google検索(ethna hidden 配列)
- 2 google検索(ethna 定義 連想配列)
- 2 google検索(argument should be an array Ethna)
- 2 google検索(ethna smarty section)
- 1 google検索(Warning: extract(): First argument should be an array in )
- 1 google検索(smarty {message name=)
- 1 google検索(simplate section name)
- 1 google検索(ethna smarty assign_by_ref)
- 1 google検索(ethna message)
- 1 google検索(Ethna_ViewClass.php error)
- 1 google検索( E_WARNING: Missing argument)
- 1 google検索([PHP] E_WARNING: Missing argument)
- 1 google検索(smarty 配列 引数)
- 1 google検索(ethna 配列)
- 1 google検索(Ethna テンプレートエンジン)
- 1 google検索(Ethna テンプレートを編集)
- 1 google検索(ethna コメントアウト)
- 1 google検索(smarty_function_message)
- 1 google検索(ethna template foreach)
- 1 google検索(simplate section)
- 1 google検索(smarty 関数 直接 strtotime)
- 1 google検索(section文)
- 1 google検索(ethna E_WARNING: Missing argument )
- 1 google検索(Ethna_SmartyPlugin サンプル)
- 1 google検索(Smarty フィルタ Ethna)
- 1 google検索(smarty extract)
- 1 google検索(register_function smarty)
- 1 google検索(extract zend framework)
- 1 google検索(ethna smarty 関数 呼び出し)
- 1 google検索(ethna getActionError)
- 1 google検索(ethna テンプレート foreach)
- 1 google検索(ethna $error)
- 1 google検索(ethna "message name=")
- 1 google検索(Smarty/Smarty.class.php ethna)
- 1 google検索(Simplate smarty)
- 1 google検索(Ethna_ViewClass.php)
- 1 google検索(Ethna tpl)
- 1 google検索(left_delimiter ethna)
- 1 google検索(ethna smartyエンジン)
- 1 google検索(ethna smarty 配列)
- 1 google検索(cakephp テンプレート コメントアウト)
- 1 http://www.google.com.vn/search?hl=vi&q=register_f...
- 1 http://www.google.com.vn/search?hl=vi&q=global.htm...
- 1 google検索(Ethna Smarty left_delimiter)
- 1 google検索(smarty foreach ethna )
- 1 google検索(smarty "Missing argument")
- 1 google検索(ethna E_WARNING: htmlspecialchars())
- 1 google検索(Smarty テンプレート php 呼び出し 連想配列)
- 1 google検索(ethna テンプレート 独自)
- 1 google検索(ethna PHPTAL)
- 1 google検索(E_WARNING: Missing argument 2 for)
- 1 google検索(iframeを使わずにhtmlを呼び出す方法)
- 1 google検索(ethna 配列 テンプレート 表示)
- 1 google検索(smary 関数 ethna)
- 1 google検索(smarty switch文)
- 1 google検索(smarty simplate 比較)
- 1 google検索(smarty login)
- 1 google検索(smarty foreach ethna)
- 1 google検索(smarty foreach Ethna)
- 1 google検索(smarty assign ethna)
- 1 google検索(smarty Missing argument)
- 1 google検索(smarty 関数 function)
- 1 google検索(smarty 連想 配列 section)
- 1 google検索(simplate section)
- 1 google検索(simplate javascript)
- 1 google検索(simplate テンプレートを)
- 1 google検索(php missing argument エラー)
- 1 google検索(php extract)
- 1 google検索(login.tpl)
- 1 google検索(iframe smarty)
- 1 google検索(foreach simplate)
- 1 google検索(ethna tpl foreach)
- 1 google検索(ethna smarty left_delimiter)
- 1 google検索(ethna smarty assign_by_ref)
- 1 google検索(ethna smarty 配列)
- 1 google検索(ethna simplate)
- 1 google検索(ethna simplate)
- 1 google検索(ethna section)
- 1 google検索(ethna linux temp)
- 1 google検索(ethna global template)
- 1 google検索(ethna global テンプレート)
- 1 google検索(ethna errors)
- 1 google検索(ethna assign)
- 1 google検索(ethna assign)
- 1 google検索(ethna テンプレート 配列)
