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

Bab 16. Extending Smarty With Plugins

Version 2.0 introduced the plugin architecture that is used for almost all the customizable functionality of Smarty. This includes:

  • functions
  • modifiers
  • block functions
  • compiler functions
  • prefilters
  • postfilters
  • outputfilters
  • resources
  • inserts
With the exception of resources, backwards compatibility with the old way of registering handler functions via register_* API is preserved. If you did not use the API but instead modified the class variables $custom_funcs, $custom_mods, and other ones directly, then you will need to adjust your scripts to either use the API or convert your custom functionality into plugins.

Bagaimana Plugin Bekerja

Plugin selalu diambil saat dibutuhkan. Hanya pengubah tertentu, fungsi, sumber daya, dll yang diminta dalam naskah template akan diambil. Selanjutnya, setiap plugin diambil hanya sekali, meskipun anda mempunyai beberapa turunan Smarty yang berjalan dalam permintaan yang sama.

Pre/postfilters dan filter output sedikit dari hal khusus. Karena tidak disetbutkan dalam template, ini harus didaftarkan atau diambil secara eksplisit melalui fungis API sebelum template diproses. Urutan di mana multipel filter dengan tipe sama dijalankan tergantung pada urutan di mana ia didaftarkan atau diambil.

Direktori plugin dapat berupa string yang berisi path atau array yang berisi multipel path. Untuk menginstalasi sebuah plugin, cukup tempatkan dalam salah satu direktori dan Smarty akan menggunakannya secara otomatis.

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors