smarty template engine
Thursday, January 08, 2009  
download | documentation | faq | forum | mailing lists | changelog | contribs 


search for in the  


Filtri di Output

I plugin filtro di output lavorano sull'output di un template, dopo che il template è stato caricato ed eseguito, ma prima che l'output che venga visualizzato.

string smarty_outputfilter_name (string $template_output, object &$smarty)

Il primo parametro passato alla funzione filtro è l'output del template che deve essere elaborato, e il secondo parametro è l'istanza di Smarty che sta chiamando il plugin. Ci si aspetta che questo effettui l'elaborazione e restituisca il risultato.

Esempio 16-9. plugin filtro di output

<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     outputfilter.protect_email.php
 * Type:     outputfilter
 * Name:     protect_email
 * Purpose:  Converts @ sign in email addresses to %40 as 
 *           a simple protection against spambots
 * -------------------------------------------------------------
 */
 
function smarty_outputfilter_protect_email($output, &$smarty)
 {
     return 
preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
                         
'$1%40$2'$output);
 }
?>



 

credits 

Smarty Copyright © 2002-2008
New Digital Group, Inc.

All rights reserved.