2011-01-09 7 views

答えて

1

テンプレートエンジンは、プレゼンテーションロジックからビジネスロジック(要求自体を)分離するために発明されました。テンプレートエンジンは$ _GET、$ _POST、$ _SESSIONなどを処理するべきではありません。

$ _GET ['action']に基づいて決定する必要がある場合は、コントローラからスマートフォンのassign 。とにかく

、あなたのコードは、あなたがそうのように$smarty.get.action

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

感謝!私は値を$ _GET ['action'] = 'detail''に代入したいと思います: '{if($ smarty.get.action =' detail ')class ="現在 "{/ if}'エラーを受け取ります – Cheerio

+0

@Mini: '{if($ smarty.get.action eq 'detail')class ="現在 "{/ if}' – zerkms

+0

@zerkms: = '詳細')} class = "現在の" {/ if} '==またはeqは何ですか?ありがとう – Cheerio

1

を使用することができ、より論理的かつ明白にしたくない場合は:

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

ありがとう!私は 'if($ _GET ['action'] == 'open'){}'を使ってマニュアルや文書がありますか? – Cheerio

+0

Aye。役に立つべきドキュメントがいくつかあります:http://www.smarty.net/docsv2/en/language.function.if.tplとhttp://www.smarty.net/docsv2/en/language.variables.smarty。 tpl#language.variables.smarty.request – borkweb

+0

すごく簡単です。私はちょうど正しいコード '{if($ smarty.get.action == 'details')}クラス="現在 "{/ if}' :)を見つけました。 – Cheerio

関連する問題