LoginSignup
0
0

More than 3 years have passed since last update.

NOREN 条件文の書き方!

Posted at

NORENでの条件文の書き方についてまとめました。

●IF/Then/Else
・・・条件により分岐処理を行う。If文をネストさせることも可能。
   Ifの属性のなかで「exist」と「is」は同時に使用できない。

 例1.表示するコンテンツにサムネイル(画像)が登録されている場合のみ、サムネイル(画像)を表示する。

[[--ActionStart,row:*--]]
[[--IfStart,exist:ArtImage--]]
[[--ThenStart--]]
<img src="[[--ArtImage--]]">
[[--ThenEnd--]]
[[--IfEnd--]]
[[--ActionEnd--]]

例2.表示するコンテンツでアクションフィールド「check」の値が「yes」の場合、アクションフィールドの値を表示する。

[[--IfStart,is:check=yes--]]
[[--ThenStart--]]
[[--ArtFieldValue,field:check--]]
[[--ThenEnd--]]
[[--IfEnd--]]

例3.「kuma」というIDのアクションフィールドが登録されていない条件下において、変数「kuma」に格納されている値が「yes」の場合、変数の値を表示する。

[[--IfStart,is:kuma=yes--]]
[[--ThenStart--]]
[[--Write,name:kuma--]]
[[--ThenEnd--]]
[[--IfEnd--]]

例4.表示するコンテンツにサムネイル(画像)が登録されている場合サムネイル(画像)を表示し、サムネイル(画像)が登録されていない場合は「閉店ガラガラ」というテキストを表示する。

[[--ActionStart,row:*--]]
[[--IfStart,exist:ArtImage--]]
[[--ThenStart--]]
<img src="[[--ArtImage--]]">
[[--ThenEnd--]]
[[--ElseStart--]]
閉店ガラガラ
[[--ElseEnd--]]
[[--IfEnd--]]
[[--ActionEnd--]]

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0