Categories > TinyButStrong general >

Multiple conditions

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Rudy
Date: 2007-10-15
Time: 23:42

Multiple conditions

Hello,

I've already searched this forum for a while, but could not find an answer to my problem. Basically I want to implement conditional sections which depend on two or more conditions.

e.g. a block "myblock" which should not show up depending on the state of the global vars a, b and c (pseudo-code follows)
<div>[myblock;block=div;when ([var.a]='foo' and [var.b]='bar') or [var.c]='foobar']
<p>[myblock.content]</p>
</div>

Is there any way to accomplish that on the template side or do I have to clear the blocks manually by merging the block on PHP-side using 'clear' after checking the values of a,b and c?

Any tips are appreciated, thank You. Keep up the good work!
By: Skrol29
Date: 2007-10-16
Time: 02:08

Re: Multiple conditions

Hello Rudy,

The answer is here:
  http://www.tinybutstrong.com/support.php#faq_or
By: Rudy
Date: 2007-10-16
Time: 12:30

Re: Multiple conditions

Thank You!
By: Rudy
Date: 2007-10-16
Time: 20:32

Re: Multiple conditions

This is very nice. For those who have the same problem, here's my solution, thanks to Skrol29's advice:
PHP:
function myblock_canshow($field, &$value) {
  global $a, $b, $c;
  $value = (($a == 'foo' && $b == 'bar') || $c == 'foobar') ? 'yes' : 'no');
}

Template:
<div>[myblock;block=div;when [onload;onformat=myblock_canshow]='yes']
<p>[myblock.content]</p>
</div>

Works like a charm now - I love TBS.