Categories > TinyButStrong general >

Conditional within repeating block

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Pedro
Date: 2005-01-05
Time: 03:10

Conditional within repeating block

How do I put a conditional block in a block that reads from an array nested in an array?  Each of the internal arrays contain entries.  There is a variable in each array that I want to check for each entry, and output something if that variable is true.  It checks the variable the first time, but that's it.  How do I get it to check each time the block cycles?  Any help is appreciated.
By: Skrol29
Date: 2005-01-05
Time: 10:35

Re: Conditional within repeating block

Hi Perdo,

They are several ways.

If you have not a lot of records in your array, then you can use a [onshow] conditionial block in your main block. The conditional block will be repeated as much as there are records. This is a bad solution if you have more than about 10 records.

You can aslo use the parameter 'onsection' to cancel the display of a specific record. The function that you code for 'onsection' has an argument $DetailSrc which returns the source of the section to merge.
If you code $DetailSrc='' in your function, then it cancels the section, only for the current record.
Think to declare the argument $DetailSrc with a '&' prefix, like this: &$DetailSrc.

Another solution is to make a second Php array with not copied records but linked records to you main array. Example:
$filter = array();
$iMax = count($data)-1;
for ($i=0;i$<=$iMax;i++) {
  if ($data[$i][flag]==1) {
     $filter = &$data[$i];
  }
}