| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  | <?xml version="1.0" encoding="iso-8859-1"?> | 
					
						
							|  |  |  | <!-- $Revision$ --> | 
					
						
							| 
									
										
										
										
											2004-07-16 14:32:31 +00:00
										 |  |  | <!-- EN-Revision: 1.2 Maintainer: andreas Status: ready --> | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |   <sect1 id="plugins.compiler.functions"><title>Compiler-Funktionen</title> | 
					
						
							|  |  |  |    <para> | 
					
						
							|  |  |  |     Compiler-Funktionen werden während der Kompilierung des Template | 
					
						
							|  |  |  |     aufgerufen. Das ist nützlich, um PHP-Code oder zeitkritische statische | 
					
						
							|  |  |  |     Inhalte in ein Template einzufügen. Sind eine Compiler-Funktion und | 
					
						
							|  |  |  |     eine eigene Funktion unter dem selben Namen registriert, wird die | 
					
						
							|  |  |  |     Compiler-Funktion ausgeführt. | 
					
						
							|  |  |  |    </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> | 
					
						
							|  |  |  |     Die Compiler-Funktion erhält zwei Parameter: die Tag-Argument Zeichenkette | 
					
						
							|  |  |  |     - also alles ab dem Funktionsnamen bis zum schliessenden Trennzeichen - und | 
					
						
							|  |  |  |     das Smarty Objekt. Gibt den PHP-Code zurück, der in das Template eingefügt werden | 
					
						
							|  |  |  |     soll. | 
					
						
							|  |  |  |    </para> | 
					
						
							|  |  |  |    <para> | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     Sehen Sie dazu: | 
					
						
							|  |  |  |     <link linkend="api.register.compiler.function">register_compiler_function()</link>, | 
					
						
							|  |  |  |      <link linkend="api.unregister.compiler.function">unregister_compiler_function()</link>. | 
					
						
							|  |  |  |    </para> | 
					
						
							|  |  |  |    <example> | 
					
						
							|  |  |  |     <title>Einfache Compiler-Funktionen</title> | 
					
						
							|  |  |  |     <programlisting> | 
					
						
							| 
									
										
										
										
											2004-07-16 14:32:31 +00:00
										 |  |  | <![CDATA[ | 
					
						
							|  |  |  | <?php | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Smarty plugin | 
					
						
							|  |  |  |  * ------------------------------------------------------------- | 
					
						
							|  |  |  |  * File:     compiler.tplheader.php | 
					
						
							|  |  |  |  * Type:     compiler | 
					
						
							|  |  |  |  * Name:     tplheader | 
					
						
							|  |  |  |  * Purpose:  Output header containing the source file name and | 
					
						
							|  |  |  |  *           the time it was compiled. | 
					
						
							|  |  |  |  * ------------------------------------------------------------- | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | function smarty_compiler_tplheader($tag_arg, &$smarty) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ?> | 
					
						
							|  |  |  | ]]> | 
					
						
							|  |  |  |      </programlisting> | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |      <para> | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       Diese Funktion kann aus dem Template wie folgt aufgerufen werden: | 
					
						
							|  |  |  |      </para> | 
					
						
							|  |  |  |      <programlisting> | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       {* diese Funktion wird nur zum Kompilier-Zeitpunkt ausgeführt *} | 
					
						
							|  |  |  |       {tplheader}</programlisting> | 
					
						
							|  |  |  |       <para> | 
					
						
							|  |  |  |         | 
					
						
							|  |  |  |        Der resultierende PHP-Code würde ungefähr so aussehen: | 
					
						
							|  |  |  |       </para> | 
					
						
							|  |  |  |       <programlisting> | 
					
						
							| 
									
										
										
										
											2004-07-16 14:32:31 +00:00
										 |  |  | <![CDATA[ | 
					
						
							|  |  |  | <?php | 
					
						
							|  |  |  | echo 'index.tpl compiled at 2002-02-20 20:02'; | 
					
						
							|  |  |  | ?> | 
					
						
							|  |  |  | ]]> | 
					
						
							|  |  |  |        </programlisting> | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |    </example> | 
					
						
							|  |  |  | </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 | 
					
						
							| 
									
										
										
										
											2004-07-16 14:32:31 +00:00
										 |  |  | --> |