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

Verzeichnis suchen
Smarty模板編譯引擎 I.開始 第一章. 什么是Smarty? 第二章. 安裝 要求 基本安裝 擴(kuò)展設(shè)置 II.模板設(shè)計(jì)者篇 第三章.基本語法 注釋 函數(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)試控制臺 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 第十五章.高級特點(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 Ⅳ.高級特點(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)資源 第二十章. 漏洞
Figuren

include_php

Attribute Name Type Required Default Description
file string Yes n/a The name of the php file to include
once boolean No true whether or not to include the php file more than once if included multiple times
assign string No n/a The name of the variable that the output of include_php will be assigned to

屬性 類型 是否必須 缺省值 描述
file string Yes n/a 待包含php文件的名稱
once boolean No true 如果待包含php文件已被包含是否仍然包含(類似php中的include_once函數(shù))
assign string No n/a 該屬性指定一個(gè)變量保存待包含php文件的輸出

include_php tags are used to include a php script in your template. If security is enabled, then the php script must be located in the $trusted_dir path. The include_php tag must have the attribute "file", which contains the path to the included php file, either relative to $trusted_dir, or an absolute path.

inluce_php 函數(shù)用于在模板中包含 php 腳本. 如果設(shè)置了安全模式,被包含的腳本必須位于 $trusted_dir 路徑下. include_php 函數(shù)必須設(shè)置 file 屬性,該屬性指明被包含 php 文件的路徑,可以是 $trusted_dir 的相對路徑,也可以是絕對路徑.

include_php is a nice way to handle componentized templates, and keep PHP code separate from the template files. Lets say you have a template that shows your site navigation, which is pulled dynamically from a database. You can keep your PHP logic that grabs database content in a separate directory, and include it at the top of the template. Now you can include this template anywhere without worrying if the database information was assigned by the application before hand.

include_php 是解決模板部件化的好方法,它使得 php 代碼從模板文件中被分離出來. 舉個(gè)例子:假設(shè)有一個(gè)從數(shù)據(jù)庫中動(dòng)態(tài)取出數(shù)據(jù)用于顯示站點(diǎn)導(dǎo)航的模板,你可以將得數(shù)據(jù)內(nèi)容的 php 邏輯部分分離出來保存在一個(gè)單獨(dú)的文件夾下,并在模板開始的位置包含該 php 腳本. 那么就可以在任何地方包含此模板而不用擔(dān)心之前數(shù)據(jù)庫信息是否已被程序取出.

By default, php files are only included once even if called multiple times in the template. You can specify that it should be included every time with the once attribute. Setting once to false will include the php script each time it is included in the template.

即使是在模板中多次地調(diào)用 php 文件,默認(rèn)情況下它們只被包含一次. 你可以設(shè)置 once 屬性從而指明每次調(diào)用都重新包含該文件. 如果將 once 屬性設(shè)置為 false,每次調(diào)用該文件都將被重新包含.

You can optionally pass the assign attribute, which will specify a template variable name that the output of include_php will be assigned to instead of displayed.

如果設(shè)置了 assign 屬性,該屬性對應(yīng)的變量名用于保存待包含 php 的輸出,這樣待包含 php 文件的輸出就不會(huì)直接顯示了。

The smarty object is available as $this within the PHP script that you include.

在待包含 php 文件中可以通過 $this 訪問 smarty 對象.

Example 7-9. function include_php
例 7-9. include_php 函數(shù)演示

load_nav.php
-------------

<?php

	// load in variables from a mysql db and assign them to the template
	// 從mysql數(shù)據(jù)庫中取得數(shù)據(jù),將數(shù)據(jù)賦給模板變量
require_once("MySQL.class.php"); $sql = new MySQL; $sql->query("select * from site_nav_sections order by name",SQL_ALL); $this->assign('sections',$sql->record); ?> index.tpl --------- {* absolute path, or relative to $trusted_dir *} {* 絕對路徑或 $trusted_dir 的相對路徑 *} {include_php file="/path/to/load_nav.php"} {foreach item="curr_section" from=$sections} <a href="{$curr_section.url}">{$curr_section.name}</a><br> {/foreach}
?
Vorheriger Artikel: N?chster Artikel: