Using declared_vars or GET vars in show_if


(Evan Wills) #1

Is it possible to use either declared variables and/or HTTP GET variables as the test value in a show_if statement?

 

e.g.

<MySource_AREA id_name="get_vars" design_area="request_vars">
  <MySource_SET name="method" value="get" />
</MySource_AREA>
<MySource_AREA id_name="show_myGetVar_value" design_area="show_if">
<MySource_SET name="condition" value="request_vars"/>
<MySource_SET name="condition_request_var" value="myGetVar" />
  <MySource_SET name="condition_request_var_match" value="true" />
  <MySource_THEN>myGetVar = true</MySource_THEN>
  <MySource_ELSE>myGetVar = false</MySource_ELSE>
</MySource_AREA>

I'm trying to switch between asset listings based on a get variable.


(Bart Banda) #2

You could use the keyword regex condition (http://manuals.matrix.squizsuite.net/designs/chapters/show-if-design-area#keyword-regexp) and check the value of globals_get_value as the keyword to match on. 

 

Also try the server  variable condition http://manuals.matrix.squizsuite.net/designs/chapters/show-if-design-area#server-variableand check on QUERY_STRING server value. 


(Evan Wills) #3

Hi Bart

 

Thanks for that. I'll have a go and report back.


(Evan Wills) #4

Hi again Bart

 

Thanks for that tip. Keyword regexp on globals_get_[value] worked a treat.

<MySource_AREA id_name="show_myGetVar_value" design_area="show_if" print="no">
  <MySource_SET name="condition" value="keyword_regexp" />
  <MySource_SET name="condition_keyword" value="globals_get_myGetVar" />
  <MySource_SET name="condition_keyword_match" value="true" />
  <MySource_THEN>myGetVar = true</MySource_THEN>
  <MySource_ELSE>myGetVar = false</MySource_ELSE>
</MySource_AREA>