Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

Name

register_resource() — リソースプラグインを動的に登録します。

説明

void register_resource(string name,
                       array resource_funcs);

リソースプラグイン を動的に登録します。パラメータとして、 リソース名および実行する PHP ユーザ定義関数の名前を格納した配列を渡します。 テンプレートを取得するための関数の定義の仕方は、 テンプレートリソース の項を参照してください。

テクニカルノート

リソース名の長さは少なくとも2文字以上である必要があります。 1文字のリソース名は無視され、$smarty->display('c:/path/to/index.tpl'); のようにファイルパスの一部として使用されます。

  • PHP関数名が含まれる配列 resource_funcs には4つまたは5つの要素が必要です。

  • 要素が4つの場合は、sourcetimestampsecure および trusted がリソースの関数としてそれぞれコールバックされます。

  • 要素が5つの場合は、最初の要素はリソースを実装するオブジェクトの参照または オブジェクトのクラス名またはクラスである必要があり、続く4つの要素は sourcetimestampsecure および trusted を実装したメソッド名である必要があります。

Example 13.25. register_resource()


<?php
$smarty->register_resource('db', array(
                                'db_get_template',
                                'db_get_timestamp',
                                'db_get_secure',
                                'db_get_trusted')
                                );
?>

   

unregister_resource() および テンプレートリソース も参照してください。

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors