Get Smarty

Donate

Donate Bitcoin Bitcoin
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

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

�置/�置过滤器

�置过滤器和�置过滤器在概念上�常相似,��点仅在于执行的时机。

string smarty_prefilter_name( $source,  
  $template);  
string $source;
object $template;
 

�置过滤器是在模���被编译�的时刻执行。 第一个�数是模���,���能已被其他过滤器处�过的。 �置过滤器�件将处�并返回过滤�的��。 注�这些返回的���会被�存,它们仅�供给编译使用。

string smarty_postfilter_name( $compiled,  
  $template);  
string $compiled;
object $template;
 

�置过滤器会在编译器已�把模�编译完�,但未�存到文件系统的时候执行。 第一个�数是已编译的代�,代��能被其他过滤器处�过的。 �置过滤器将进行处�并返回处��的代�。

Example 18.7. �置过滤器


<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     prefilter.pre01.php
 * Type:     prefilter
 * Name:     pre01
 * Purpose:  转�HTML标签为�写
 * -------------------------------------------------------------
 */
 function smarty_prefilter_pre01($source, Smarty_Internal_Template $template)
 {
     return preg_replace('!<(\w+)[^>]+>!e', 'strtolower("$1")', $source);
 }
?>

     

Example 18.8. �置过滤器


<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     postfilter.post01.php
 * Type:     postfilter
 * Name:     post01
 * Purpose:  列出当�模�的��
 * -------------------------------------------------------------
 */
 function smarty_postfilter_post01($compiled, Smarty_Internal_Template $template)
 {
     $compiled = "<pre>\n<?php print_r(\$template->getTemplateVars()); ?>\n</pre>" . $compiled;
     return $compiled;
 }
?>

     

��: registerFilter() 和 unregisterFilter().

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 11 plus 8? (Are you human?)

Advertisement