亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

?? ??? ??
Smarty模板編譯引擎 I.開(kāi)始 第一章. 什么是Smarty? 第二章. 安裝 要求 基本安裝 擴(kuò)展設(shè)置 II.模板設(shè)計(jì)者篇 第三章.基本語(yǔ)法 注釋 函數(shù) 屬性 第四章.變量 從PHP分配的變量 Associative arrays Array indexes Objects 從配置文件讀取的變量 {$smarty}保留變量 Request variables {$smarty.now} {$smarty.const} {$smarty.capture} {$smarty.config} {$smarty.section} {$smarty.template} 第五章.變量調(diào)節(jié)器 capitalize count_characters cat count_paragraphs count_sentences count_words date_format default escape indent lower nl2br regex_replace replace spacify string_format strip strip_tags truncate upper wordwrap 第六章.組合修改器 第七章.內(nèi)建函數(shù) capture config_load foreach include include_php insert if ldelim literal php section index index_prev index_next iteration first last rownum loop show total strip 第八章.自定義函數(shù) assign counter cycle debug eval fetch html_checkboxes html_image html_options html_radios html_select_date html_select_time html_table math mailto popup_init popup textformat 第九章.配置文件 第十章.調(diào)試控制臺(tái) III.模板程序員篇 第十一章 常量 SMARTY_DIR 第十二章 變量 $template_dir $compile_dir $config_dir $plugins_dir $debugging $debug_tpl $debugging_ctrl $global_assign $undefined $autoload_filters $compile_check $force_compile $caching $cache_dir $cache_lifetime $cache_handler_func $cache_modified_check $config_overwrite $config_booleanize $config_read_hidden $config_fix_newlines $default_template_handler_func $php_handling $security $secure_dir $security_settings $trusted_dir $left_delimiter $right_delimiter $compiler_class $request_vars_order $compile_id $use_sub_dirs $default_modifiers $default_resource_type 第十三章.方法 append append_by_ref assign assign_by_ref clear_all_assign clear_all_cache clear_assign clear_cache clear_compiled_tpl clear_config config_load display fetch get_config_vars get_registered_object get_template_vars is_cached load_filter register_block register_compiler_function register_function register_modifier register_object register_outputfilter register_postfilter register_prefilter register_resource trigger_error template_exists unregister_block unregister_compiler_function unregister_function unregister_modifier unregister_object unregister_outputfilter unregister_postfilter unregister_prefilter unregister_resource 第十四章.緩存 Setting Up Caching Multiple Caches Per Page Cache Groups Controlling Cacheability of Plugins' Output 第十五章.高級(jí)特點(diǎn) Objects Prefilters Postfilters Output Filters Cache Handler Function Resources Templates from $template_dir Templates from any directory Templates from other sources Default template handler function 第十六章.以插件擴(kuò)展Smarty How Plugins Work Naming Conventions Writing Plugins Template Functions Modifiers Block Functions Compiler Functions Prefilters/Postfilters Output Filters Resources Inserts Ⅳ.高級(jí)特點(diǎn) 第十七章.疑難解答 Smarty/PHP errors 第18章.使用技巧和經(jīng)驗(yàn) Blank Variable Handling Default Variable Handling Passing variable title to header template Dates WAP/WML Componentized Templates Obfuscating E-mail Addresses 第十九章. 相關(guān)資源 第二十章. 漏洞
??

Block Functions塊函數(shù)

void smarty_block_ name (array $params, mixed $content, object &$smarty)

Block functions are functions of the form: {func} .. {/func}. In other words, they enclose a template block and operate on the contents of this block. Block functions take precedence over custom functions of the same name, that is, you cannot have both custom function {func} and block function {func} .. {/func}.
塊函數(shù)的形式是這樣的:{func} .. {/func}。換句話(huà)說(shuō),他們用標(biāo)記圈起一個(gè)塊,然后對(duì)這個(gè)塊的內(nèi)容進(jìn)行操作。塊函數(shù)優(yōu)先于同名的傳統(tǒng)函數(shù),即你不能同時(shí)有通明的傳統(tǒng)函數(shù){func}和塊函數(shù){func} .. {/func}。

By default your function implementation is called twice by Smarty: once for the opening tag, and once for the closing tag (see &$repeat below how to change this).
默認(rèn)地你的函數(shù)執(zhí)行被Smarty調(diào)用兩次:一次是在開(kāi)始標(biāo)記,另一次是在結(jié)束標(biāo)記(參考下面的&$repeat怎樣改變這種情況)

Only the opening tag of the block function may have attributes. All attributes passed to template functions from the template are contained in the $params as an associative array. You can either access those values directly, e.g. $params['start'] or use extract($params) to import them into the symbol table. The opening tag attributes are also accessible to your function when processing the closing tag.
塊函數(shù)僅開(kāi)始標(biāo)記可以有屬性。所有從模板傳替給模板函數(shù)的屬性被囊括與一個(gè)集合數(shù)組參數(shù)中。你可以直接獲取其值,例如:$params['start']或者是用extract($params)將它們導(dǎo)入符號(hào)表中。當(dāng)處理結(jié)束標(biāo)記時(shí),開(kāi)始標(biāo)記的屬性對(duì)你的函數(shù)也是可用的。

The value of $content variable depends on whether your function is called for the opening or closing tag. In case of the opening tag, it will be null, and in case of the closing tag it will be the contents of the template block. Note that the template block will have already been processed by Smarty, so all you will receive is the template output, not the template source.
變量 $content 的值取決于是否因開(kāi)始標(biāo)記或結(jié)束標(biāo)記調(diào)用你的函數(shù)。假如是開(kāi)始標(biāo)記,它會(huì)是空的,如果是結(jié)束標(biāo)記,它會(huì)是模板塊的內(nèi)容。請(qǐng)注意模板塊已經(jīng)被Smarty處理,所以你接收到的結(jié)果是輸出后的模板而不是原樣模板。

The parameter &$repeat is passed by reference to the function implementation and provides a possibility for it to control how many times the block is displayed. By default $repeat is true at the first call of the block-function (the block opening tag) and false on all subsequent calls to the block function (the block's closing tag). Each time the function implementation returns with &$repeat being true, the contents between {func} .. {/func} are evaluated and the function implementation is called again with the new block contents in the parameter $content .
參數(shù) &$repeat 通過(guò)參考引用傳遞給函數(shù)執(zhí)行過(guò)程并為其提供一個(gè)可能值來(lái)控制顯示塊多少遍。默認(rèn)情況下在首次調(diào)用塊函數(shù)(塊開(kāi)始標(biāo)記)時(shí)變量 $repeat 是真,在隨后的所有塊函數(shù)調(diào)用中其始終是假。每當(dāng)函數(shù)執(zhí)行返回的 &$repeat 是真時(shí),在{func} .. {/func}之間的內(nèi)容再次求值,函數(shù)執(zhí)行接收一個(gè)新塊參數(shù) $content 內(nèi)容值被再次調(diào)用。

If you have nested block functions, it's possible to find out what the parent block function is by accessing $smarty->_tag_stack variable. Just do a var_dump() on it and the structure should be apparent.
如果你嵌套了塊函數(shù),通過(guò)訪(fǎng)問(wèn)變量$smarty->_tag_stack 找出父塊函數(shù)是可能的。僅僅對(duì)塊函數(shù)運(yùn)行一下var_dump(),函數(shù)結(jié)構(gòu)就會(huì)一目了然了。

See also: register_block(), unregister_block().

Example 16-5. block function

<?php

function smarty_block_translate($params, $content, &$smarty)
{
 if (isset($content)) {
 $lang = $params['lang'];
 // do some intelligent translation thing here with $content
 return $translation;
 }
}
?? ??: ?? ??: