Php-Smarty-7 (24), phpsmarty-724
Iii. Methods
L assign: assign variables to the template
L assignByRef: Assign variables to the template (pass by reference)
Difference between Display and fetch:
Iv. Filter
A filter is used to filter data.
1. filter types:
1) prefilter Prefilters
2) Postfilters
3) Output filter Output Filters
Based on the trigger time, the above three filters are divided
2. Workflow
Tpl source file => Prefilter => compile tpl file => Postfilter => Save to disk => run the compiled PHP file => Output Filters (=> if there is a smarty cache, output Filters content will be cached) => result Output.
3. Register a filter
In Smarty, the filter must be registered before use
In 2.6, register the filter
L Prefilters
$ Smarty-> register_prefilter ("func ");
L Postfilters
$ Smarty-> register_postfilter ("func ");
L Output Filters
$ Smarty-> register_outputfilter ("func ");
Register different filters to call different methods.
3.0, register the filter
$ Smarty-> registerFilter ($ type, $ callback );
$ Type: Filter type
Value range:
Pre: Pre-filter
Post: Post Filter
Output: Output filter
$ Callback: Filter Function
4. Code:
The pre-filter and post-filter will be executed during the first compilation, or the template will be executed again after the template changes.
The output filter is executed every time.