[英]Integrate PHP code in Smarty templates
我使用Smarty來實現我的模板。 我怎么能寫這個PHP句子。
<?php if(empty($_GET['action'])) { echo class="current"; } ?>
發明模板引擎是為了將業務邏輯(和請求本身)與表示邏輯分開。 模板引擎不應該處理$ _GET,$ _POST,$ _SESSION等。
如果您需要根據$ _GET ['action']做出決定 - 那么只需通過reguler smarty的assign
從控制器傳遞它。
無論如何,如果你不希望你的代碼更符合邏輯和明顯,你可以使用$smarty.get.action
{if empty($smarty.get.action)}class="current"{/if}
像這樣:
{if !isset($smarty.get.action)}class="current"{/if}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.