茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1673006 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00023.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2010/3/10 8:03:35

前面所提到的 ldelim 和 rdelim 是 smarty 的保留字,也是 smarty 的內定變數

保留的 {$smarty} 變數可以用來取得某些相當特殊的樣版變數,這些變數的說明如下:

Request variables

The request variables such as get, post, cookies, server, environment, and session variables can be accessed as demonstrated in the examples below:

要求變數如 get, post, cookies, server, environment 與 session 等變數取得方式如下:

Example 4-6. 展示所要求的變數

{* display value of page from URL (GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page}

{* display the variable "page" from a form (POST) *}
{$smarty.post.page}

{* display the value of the cookie "username" *}
{$smarty.cookies.username}

{* display the server variable "SERVER_NAME" *}
{$smarty.server.SERVER_NAME}

{* display the system environment variable "PATH" *}
{$smarty.env.PATH}

{* display the php session variable "id" *}
{$smarty.session.id}

{* display the variable "username" from merged get/post/cookies/server/env *}
{$smarty.request.username}


Note: For historical reasons {$SCRIPT_NAME} can be accessed directly though {$smarty.server.SCRIPT_NAME} is the proposed way to access this value.

提醒: 因為使用習慣的原因,我們建議使用 {$smarty.server.SCRIPT_NAME} 變數取得 {$SCRIPT_NAME} 的值。



{$smarty.now}

The current timestamp can be accessed with {$smarty.now}. The number reflects the number of seconds passed since the so-called Epoch (January 1, 1970) and can be passed directly to date_format modifier for display purposes.

我們可以使用 {$smarty.now} 取得現在的時間戳記,得到的數字代表從1970 年1月1日開始到現在的秒數,我們可以將得到的數字傳給 date_format 修飾字。

Example 4-7. 使用 {$smarty.now}
{* use the date_format modifier to show current date and time *}
{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}




{$smarty.const}

You can access PHP constant values directly.

我們可以直接取得 PHP 常數變數。

Example 4-8. 使用 {$smarty.const}
{$smarty.const._MY_CONST_VAL}




{$smarty.capture}

The output captured via {capture}..{/capture} construct can be accessed using {$smarty} variable. See section on capture for an example.

由 {capture}..{/capture} 獲得的輸出變數可以使用 {$smarty} 取得,範例請參閱 capture。



{$smarty.config}

{$smarty} variable can be used to refer to loaded config variables. {$smarty.config.foo} is a synonym for {#foo#}. See the section on config_load for an example.

{$smarty} 變數可以用來參照到已載入的組態變數,如 {$smarty.config.foo} 同義於 {#foo#},範例請參閱 config_load。



{$smarty.section}, {$smarty.foreach}

{$smarty} variable can be used to refer to 'section' and 'foreach' loop properties. See docs for section and foreach.

{$smarty} 變數可以用來參照到 'section' 與 'foreach' 等遞迴屬性,請參閱 section 與 foreach 文件。



{$smarty.template}

This variable contains the name of the current template being processed.

此參數內容為現在正在處理的樣版名稱。



{$smarty.version}

This variable contains the version of Smarty the template was compiled with.

此參數內容為 Smarty 的版本數字。



{$smarty.ldelim}

This variable is used for printing the left-delimiter value literally. See also {ldelim},{rdelim}.

此變數用來列印出左阻斷符號,請參閱 {ldelim},{rdelim}。



{$smarty.rdelim}

This variable is used for printing the right-delimiter value literally. See also {ldelim},{rdelim}.

此變數用來列印出右阻斷符號,請參閱 {ldelim},{rdelim}。


本篇所要討論的 ldelim 和 rdelim 使用法如下:

ldelim,rdelim

ldelim and rdelim are used for escaping template delimiters, in our case "{" or "}". You can also use {literal}{/literal} to escape blocks of text. See also {$smarty.ldelim} and {$smarty.rdelim}

ldelim 與 rdelim 是用來作為樣版阻斷符號脫序的,在我們的範例中是 "{" 或 "}"。你也可以使用 {literal}{/literal} 將區塊中的文字脫序。請參閱 {$smarty.ldelim} 與 {$smarty.rdelim}

Example 7-12. ldelim, rdelim

{* this will print literal delimiters out of the template *}
{ldelim}funcname{rdelim} is how functions look in Smarty!
The above example will output:
上面例子的輸出結果為:
{funcname} is how functions look in Smarty!


原文出處:

{$smarty} reserved variable

ldelim,rdelim
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|