开发者

Integrate PHP code in Smarty templates

I use Smarty to implement my template. 开发者_运维问答How can I write this PHP sentence.

<?php if(empty($_GET['action'])) { echo class="current"; } ?>


Template engines were invented to separate business logic (and the request itself) from presentational logic. Template engine should not take care of $_GET, $_POST, $_SESSION, etc.

If you need to make a decision based on $_GET['action'] - then just pass it from your controller with reguler smarty's assign.

Anyway, if you don't want your code to be more logical and obvious you could use $smarty.get.action

{if empty($smarty.get.action)}class="current"{/if}


Like so:

{if !isset($smarty.get.action)}class="current"{/if}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜