Lesson 11: Modes and Conditional Flow

With cases where you wish to create a more complex script with multiple modes, The [[IF_EQUAL]], and forms of [[ELSE]] are generally used. Note that you should use the default mode for handling posted data.

Create a node and paste this following code into it’s landing page editor. Goto the node’s address and test with browser. Add /?mode=1 to the end of the node url. Try modes 2,3 and 4.  The script should output “This is Mode1” if you typed /?mode=1 in the node’s url address. Note that if you already added the forward slash at the end of the node url then you dont need a second one before the question mark but you must have one before the question mark when using node addresses.

 [[QUERY_STRING:mode]]
 [[IF_EQUAL:$mode|"1"]]
 This is Mode1
 [[ELSE_IF:$mode=="2"]]
 This is Mode2
 [[ELSE_IF:$mode=="3"]]
 This is Mode3
 [[ELSE_IF:$mode=="4"]]
 This is Mode4
 [[ELSE]]
 Default
 [[END_IF]]

Leave a Reply