Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:create:filter-boolean [28.11.2014 13:37] – [Check If a Selection has the One OR Another Value] alexander.ritteren:create:filter-boolean [07.12.2023 12:31] (current) – Nested Filters empschul
Line 8: Line 8:
   * Does the participant usually buy -- according to a multiple-choice --  chocolate **and** dairy products?    * Does the participant usually buy -- according to a multiple-choice --  chocolate **and** dairy products? 
  
-So-called "logical operators" (also known as "Boolean operators", see [[http://php.net/manual/en/language.operators.logical.php|PHP: Logical Operators]]) aid the linking of conditions. Three operators are required particularly frequently:+These "logical operators" (also known as "Boolean operators", see [[http://php.net/manual/en/language.operators.logical.php|PHP: Logical Operators]]) aid the linking of conditions. Three operators are required particularly frequently:
  
   * The AND operator (''and'' or ''&&'') links two conditions and checks if both conditions are true.    * The AND operator (''and'' or ''&&'') links two conditions and checks if both conditions are true. 
Line 97: Line 97:
  
  
-If the values are not linked, then each condition can be looked up individually:+If the values are not linked, then each condition can be called up individually:
  
 <code php> <code php>
Line 192: Line 192:
 } else { } else {
   goToPage('end');   goToPage('end');
 +}
 +</code>
 +
 +===== Nested filters =====
 +
 +Sometimes it makes sense to set a filter in another filter. Let's take the situation where, depending on the answer to FF01, either question FF02 or FF03 was displayed. And now, depending on these two questions, another filter should follow. The individual filters would be simple:
 +
 +<code php>
 +if (value('FF02') == 1) {
 +  replace('%stimulus%', 'Dog');
 +} else {
 +  replace('%stimulus%', 'Cat');
 +}
 +</code>
 +
 +<code php>
 +if (value('FF03') == 1) {
 +  replace('%stimulus%', 'Wolf');
 +} else {
 +  replace('%stimulus%', 'Tiger');
 +}
 +</code>
 +
 +But now only one of these two filters should become active ... depending on which value FF01 had. To do this, these filters are placed "inside" another filter.
 +
 +<code php>
 +if (value('FF01') == 1) {
 +  // Filter für FF02
 +  if (value('FF02') == 1) {
 +    replace('%stimulus%', 'Dog');
 +  } else {
 +    replace('%stimulus%', 'Cat');
 +  }
 +} else {
 +  // Filter für FF03
 +  if (value('FF03') == 1) {
 +    replace('%stimulus%', 'Wolf');
 +  } else {
 +    replace('%stimulus%', 'Tiger');
 +  }
 } }
 </code> </code>
en/create/filter-boolean.1417178253.txt.gz · Last modified: 28.11.2014 13:37 by alexander.ritter
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki