国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

Smarty:capture函數

2018-10-14 11:20 更新

{capture}

{capture}可以捕獲標記范圍內的輸出內容,存到變量中而不顯示。 任何在{capture name='foo'} 和 {/capture} 之間的內容都會被捕獲到變量,變量名可以通過name屬性來指定。

捕獲的內容可以通過$smarty.capture.foo變量來使用,這里foo是設置的name屬性。 如果沒有提供name屬性,默認是default,也就是 $smarty.capture.default.

{capture}可以被嵌套使用。

屬性:

參數名稱類型必選參數默認值說明
namestringYesn/a捕獲區(qū)域的名稱
assignstringNon/a捕獲內容后賦值的變量名
appendstringNon/a將捕獲的內容增加到數組中

可選標記:

名稱說明
nocache關閉捕獲區(qū)域的緩存

警告

當捕獲{insert}輸出的時候請小心。 如果開啟了$caching并且 你希望通過{insert} 在緩存的頁面上顯示動態(tài)內容,那么你無法捕獲這些內容。

Example 7.21. {capture}使用name屬性

{* we don't want to print a div tag unless content is displayed *}
{capture name="banner"}
{capture "banner"} {* short-hand *}
  {include file="get_banner.tpl"}
{/capture}

{if $smarty.capture.banner ne ""}
<div id="banner">{$smarty.capture.banner}</div>
{/if}


Example 7.22. {capture} 捕獲內容到變量

下面是capture函數的演示

{capture name=some_content assign=popText}
{capture some_content assign=popText} {* short-hand *}
The server is {$my_server_name|upper} at {$my_server_addr}<br>
Your ip is {$my_ip}.
{/capture}
<a href="#">{$popText}</a>


Example 7.23. {capture} 捕獲內容到數組變量

下面例子演示了如何多次捕獲內容,形成數組。

{capture append="foo"}hello{/capture}I say just {capture append="foo"}world{/capture}
{foreach $foo as $text}{$text} {/foreach}

輸出:

I say just hello world

以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號