| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | <?xml version="1.0" encoding="iso-8859-1"?> | 
					
						
							|  |  |  |  | <!-- $Revision$ --> | 
					
						
							| 
									
										
										
										
											2004-05-23 15:50:53 +00:00
										 |  |  |  | <!-- EN-Revision: 1.1 Maintainer: nobody Status: partial --> | 
					
						
							|  |  |  |  | <sect1 id="plugins.compiler.functions"><title>Fonctions de compilation</title> | 
					
						
							|  |  |  |  | <para> | 
					
						
							|  |  |  |  |  Les fonctions de compilation sont appel<65>es durant la compilation du template. | 
					
						
							|  |  |  |  |  Elles sont utiles pour injecter du code PHP ou du contenu "statique variant | 
					
						
							|  |  |  |  |  avec le temps" (bandeau de pub par ex.). Si une fonction de compilation et | 
					
						
							|  |  |  |  |  une fonction personnalis<69>e ont le m<>me | 
					
						
							|  |  |  |  |  nom, la fonction de compilation a priorit<69>. | 
					
						
							|  |  |  |  | </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> | 
					
						
							|  |  |  |  |  Les fonctions de compilation ont deux param<61>tres : une chaene contenant | 
					
						
							|  |  |  |  |  la balise - en gros, tout, depuis le nom de la fonction jusqu'au d<>limiteur de fin - et | 
					
						
							|  |  |  |  |  l'objet Smarty. Elles sont cens<6E>es retourner le code PHP qui doit <20>tre | 
					
						
							|  |  |  |  |  inject<63> dans le template compil<69>. | 
					
						
							|  |  |  |  | </para> | 
					
						
							|  |  |  |  | <para> | 
					
						
							|  |  |  |  |  Regardez aussi | 
					
						
							|  |  |  |  |  <link linkend="api.register.compiler.function">register_compiler_function()</link>, | 
					
						
							|  |  |  |  |   <link linkend="api.unregister.compiler.function">unregister_compiler_function()</link>. | 
					
						
							|  |  |  |  |   </para> | 
					
						
							|  |  |  |  |   <example> | 
					
						
							|  |  |  |  |    <title>fonction de compilation simple</title> | 
					
						
							|  |  |  |  | <programlisting> | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | <?php | 
					
						
							|  |  |  |  | /* | 
					
						
							|  |  |  |  |  * Smarty plugin | 
					
						
							|  |  |  |  |  * ------------------------------------------------------------- | 
					
						
							|  |  |  |  |  * Fichier :   compiler.tplheader.php | 
					
						
							|  |  |  |  |  * Type :      compilation | 
					
						
							|  |  |  |  |  * Nom :       tplheader | 
					
						
							|  |  |  |  |  * R<>le :      Renvoie l'en-t<>te contenant le nom du fichier | 
					
						
							|  |  |  |  |  *             source et le temps de compilation. | 
					
						
							|  |  |  |  |  * ------------------------------------------------------------- | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | function smarty_compiler_tplheader($tag_arg, &$smarty) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';"; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ?></programlisting> | 
					
						
							| 
									
										
										
										
											2004-05-23 15:50:53 +00:00
										 |  |  |  |    <para> | 
					
						
							|  |  |  |  |     Cette fonction peut-<2D>tre appel<65> depuis le template comme suivant : | 
					
						
							|  |  |  |  |    </para> | 
					
						
							|  |  |  |  | <programlisting> | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | {* cette fonction n'est execut<75>e que lors de la compilation *} | 
					
						
							|  |  |  |  | {tplheader}</programlisting> | 
					
						
							| 
									
										
										
										
											2004-05-23 15:50:53 +00:00
										 |  |  |  |    <para> | 
					
						
							|  |  |  |  |     Le code PHP r<>sultant dans les templates compil<69>s ressemblerait a ta : | 
					
						
							|  |  |  |  |    </para> | 
					
						
							|  |  |  |  | <programlisting> | 
					
						
							| 
									
										
										
										
											2004-04-13 11:47:32 +00:00
										 |  |  |  | <php | 
					
						
							|  |  |  |  | echo 'index.tpl compiled at 2002-02-20 20:02'; | 
					
						
							|  |  |  |  | ?></programlisting> | 
					
						
							| 
									
										
										
										
											2004-05-23 15:50:53 +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 | 
					
						
							|  |  |  |  |  --> |