Cheerio
Cheerio

Reputation: 1240

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"; } ?>

Upvotes: 0

Views: 1408

Answers (2)

borkweb
borkweb

Reputation: 1024

Like so:

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

Upvotes: 1

zerkms
zerkms

Reputation: 254916

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}

Upvotes: 1

Related Questions