Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

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( $template_output,  
  &$smarty);  
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.

Example 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);
 }
?>

     

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors