mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-04 08:10:55 +02:00
98 lines
2.8 KiB
XML
98 lines
2.8 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<sect1 id="plugins.compiler.functions"><title>Fungsi Kompilator</title>
|
|
<para>
|
|
Fungsi kompilator dipanggil hanya selama kompilasi template.
|
|
Ini berguna untuk menginjeksi kode PHP atau isi statis sensitif-waktu
|
|
ke dalam template. Jika ada kedua fungsi kompilator dan
|
|
<link linkend="language.custom.functions">fungsi kustom</link> terdaftar
|
|
dengan nama sama, fungsi kompilator yang lebih tinggi.
|
|
</para>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef>
|
|
<paramdef>string <parameter>$tag_arg</parameter></paramdef>
|
|
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
Fungsi kompilator diberi dua parameter: argumen string tag - pada
|
|
dasarnya, apapun dari nama fungsi sampai akhir pemisah, dan obyek
|
|
Smarty. Ia seharusnya mengembalikan kode PHP yang disisipkan ke dalam
|
|
template terkompilasi.
|
|
</para>
|
|
|
|
<example>
|
|
<title>Fungsi kompilator sederhana</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/*
|
|
* Smarty plugin
|
|
* -------------------------------------------------------------
|
|
* File: compiler.tplheader.php
|
|
* Tipe: kompilator
|
|
* Nama: tplheader
|
|
* Kegunaan: Output header berisi nama file sumber dan waktu
|
|
* dikompilasinya.
|
|
* -------------------------------------------------------------
|
|
*/
|
|
function smarty_compiler_tplheader($tag_arg, &$smarty)
|
|
{
|
|
return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Fungsi ini dipanggil dari template sebagai:
|
|
</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{* fungsi ini dijalankan hanya saat waktu kompilasi *}
|
|
{tplheader}
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Kode PHP yang dihasilkan dalam template terkompilasi akan menjadi seperti ini:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo 'index.tpl compiled at 2002-02-20 20:02';
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<para>
|
|
Lihat juga
|
|
<link linkend="api.register.compiler.function">
|
|
<varname>register_compiler_function()</varname></link>,
|
|
<link linkend="api.unregister.compiler.function">
|
|
<varname>unregister_compiler_function()</varname></link>.
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|