mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-04 06:11:37 +01:00 
			
		
		
		
	
		
			
	
	
		
			108 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
		
		
			
		
	
	
			108 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
| 
								 | 
							
								<?xml version="1.0" encoding="iso-8859-1"?>
							 | 
						|||
| 
								 | 
							
								<!-- $Revision$ -->
							 | 
						|||
| 
								 | 
							
								<refentry id="api.is.cached">
							 | 
						|||
| 
								 | 
							
								 <refnamediv>
							 | 
						|||
| 
								 | 
							
								  <refname>is_cached</refname>
							 | 
						|||
| 
								 | 
							
								  <refpurpose></refpurpose>
							 | 
						|||
| 
								 | 
							
								 </refnamediv>
							 | 
						|||
| 
								 | 
							
								 <refsect1>
							 | 
						|||
| 
								 | 
							
								  <title />
							 | 
						|||
| 
								 | 
							
								  <methodsynopsis>
							 | 
						|||
| 
								 | 
							
								   <type>bool</type><methodname>is_cached</methodname>
							 | 
						|||
| 
								 | 
							
								   <methodparam><type>string</type><parameter>template</parameter></methodparam>
							 | 
						|||
| 
								 | 
							
								   <methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
							 | 
						|||
| 
								 | 
							
								   <methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
							 | 
						|||
| 
								 | 
							
								  </methodsynopsis>
							 | 
						|||
| 
								 | 
							
								  <para>
							 | 
						|||
| 
								 | 
							
								   Restituisce &true; se <20> presente una cache valida per questo template.
							 | 
						|||
| 
								 | 
							
								   Funziona soltanto se <link linkend="variable.caching">caching</link> <20>
							 | 
						|||
| 
								 | 
							
								   impostato a true.
							 | 
						|||
| 
								 | 
							
								  </para>
							 | 
						|||
| 
								 | 
							
								  <example>
							 | 
						|||
| 
								 | 
							
								   <title>is_cached</title>
							 | 
						|||
| 
								 | 
							
								   <programlisting role="php">
							 | 
						|||
| 
								 | 
							
								<![CDATA[
							 | 
						|||
| 
								 | 
							
								<?php
							 | 
						|||
| 
								 | 
							
								$smarty->caching = true;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								if(!$smarty->is_cached("index.tpl")) {
							 | 
						|||
| 
								 | 
							
								// faccio le chiamate al database, assegno le variabili
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								$smarty->display("index.tpl");
							 | 
						|||
| 
								 | 
							
								?>
							 | 
						|||
| 
								 | 
							
								]]>
							 | 
						|||
| 
								 | 
							
								   </programlisting>
							 | 
						|||
| 
								 | 
							
								  </example>
							 | 
						|||
| 
								 | 
							
								  <para>
							 | 
						|||
| 
								 | 
							
								   Potete passare anche una cache id come secondo parametro
							 | 
						|||
| 
								 | 
							
								   opzionale, nel caso vogliate cache multiple per il template
							 | 
						|||
| 
								 | 
							
								   dato.
							 | 
						|||
| 
								 | 
							
								  </para>
							 | 
						|||
| 
								 | 
							
								  <para>
							 | 
						|||
| 
								 | 
							
								   Potete fornire un compile id come terzo parametro opzionale.
							 | 
						|||
| 
								 | 
							
								   Se lo omettete, viene usato il valore della variabile persistente
							 | 
						|||
| 
								 | 
							
								   <link linkend="variable.compile.id">$compile_id</link>.
							 | 
						|||
| 
								 | 
							
								  </para>
							 | 
						|||
| 
								 | 
							
								  <para>
							 | 
						|||
| 
								 | 
							
								   Se non volete passare una cache id ma volete passare un compile
							 | 
						|||
| 
								 | 
							
								   id dovete passare <literal>null</literal> come cache id.
							 | 
						|||
| 
								 | 
							
								  </para>
							 | 
						|||
| 
								 | 
							
								  <example>
							 | 
						|||
| 
								 | 
							
								   <title>is_cached con template a cache multiple</title>
							 | 
						|||
| 
								 | 
							
								   <programlisting role="php">
							 | 
						|||
| 
								 | 
							
								<![CDATA[
							 | 
						|||
| 
								 | 
							
								<?php
							 | 
						|||
| 
								 | 
							
								$smarty->caching = true;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								if(!$smarty->is_cached("index.tpl", "FrontPage")) {
							 | 
						|||
| 
								 | 
							
								  // faccio le chiamate al database, assegno le variabili
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								$smarty->display("index.tpl", "FrontPage");
							 | 
						|||
| 
								 | 
							
								?>
							 | 
						|||
| 
								 | 
							
								]]>
							 | 
						|||
| 
								 | 
							
								   </programlisting>
							 | 
						|||
| 
								 | 
							
								  </example>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								  <note>
							 | 
						|||
| 
								 | 
							
								  <title>Nota tecnica</title>
							 | 
						|||
| 
								 | 
							
								  <para>
							 | 
						|||
| 
								 | 
							
								   Se <literal>is_cached</literal> restituisce true, in realt<6C> carica
							 | 
						|||
| 
								 | 
							
								   l'output in cache e lo memorizza internamente. Ogni chiamata
							 | 
						|||
| 
								 | 
							
								   successiva a <link linkend="api.display">display()</link> o a 
							 | 
						|||
| 
								 | 
							
								   <link linkend="api.fetch">fetch()</link> restituir<69> questo output
							 | 
						|||
| 
								 | 
							
								   memorizzato internamente, e non cercher<65> di ricaricare il file
							 | 
						|||
| 
								 | 
							
								   della cache. Questo evita una situazione che potrebbe verificarsi
							 | 
						|||
| 
								 | 
							
								   quando un secondo processo elimina la cache nell'intervallo fra
							 | 
						|||
| 
								 | 
							
								   la chiamata a is_cached e quella a display, nell'esempio visto
							 | 
						|||
| 
								 | 
							
								   prima. Questo significa anche che le chiamate a
							 | 
						|||
| 
								 | 
							
								   <link linkend="api.clear.cache">clear_cache()</link> ed altre
							 | 
						|||
| 
								 | 
							
								   modifiche fatte sulle impostazioni della cache potrebbero non avere
							 | 
						|||
| 
								 | 
							
								   effetto dopo che <literal>is_cached</literal> ha restituito true.
							 | 
						|||
| 
								 | 
							
								  </para>
							 | 
						|||
| 
								 | 
							
								  </note>
							 | 
						|||
| 
								 | 
							
								 </refsect1>
							 | 
						|||
| 
								 | 
							
								</refentry>
							 | 
						|||
| 
								 | 
							
								<!-- 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
							 | 
						|||
| 
								 | 
							
								-->
							 |