2014-03-01 27 views
0

我是新來使用Smarty模板系統,並希望有人能幫助我。在smarty模板系統中使用if/else?

如果{$clientsdetails.customfields1}空或空白,我想讓它顯示「不工作」的消息。如果有在該字段中輸入任何東西,我想讓它顯示消息「當前工作」。

+0

http://www.smarty.net/docsv2/ EN/language.function.if.tpl – barell

回答

0

試試這個代碼:

{if $clientsdetails.customfields1==""} 
    not working 
{else} 
    currently working 
{/if} 
1

試試這個:

{if empty($clientsdetails.customfields1)} 
    <p>Not Working</p> 
{else} 
    <p>Currently Working</p> 
{/if} 

這將或者檢查是否$ clientsdetails.customfields1沒有設置,如果它等於false。

在PHP所有這些都被認爲是假的:

  • 0.0
  • 「」
  • 「0」

如果沒有設置或== fa倫敦政治經濟學院,它會顯示 '不工作',否則 '目前工作'

文檔的詳細信息:http://www.smarty.net/docs/en/language.function.if.tpl