By: fpierrat
Date: 2011-10-06
Time: 21:44
|
Conditional block - when paramHi,
I'd like to have a section that only appears when a condition is verified (in the example below: when $lg['a_test'] is set to 'ok') Looked through the doc, thought it could look like this:
It doesn't work. Just for tests and to better understand the "when" param, I tried to replace it with
|
|||
By: Skrol29
Date: 2011-10-06
Time: 23:43
|
Re: Conditional block - when paramHi,
I've tested your snippet "as is", and it works very well for me. The problem you have may come with the data you are merging. What is you version of TBS ? Did you know that conditional sections are exclusive between each other, unless you are using parameter "several" ? |
|||
By: fpierrat
Date: 2011-10-07
Time: 08:39
|
Re: Conditional block - when paramThanks,
"several": i didn't know anything of this point, I'll check, but it could be part of my problem (there's another conditional section before, but I just sent the most "regular", most easy to read ones). Data: I had tries with simply showing [lg.a_test] and [lg.b_test], some records show "ok", other show "empty" so I don't think the problem comes from my data... I'll tell you if the problem comes from "several" as soon as tested, Thanks again for the rapid answer, it's very important while trying/testing a new tool! |
|||
By: fpierrat
Date: 2011-10-07
Time: 09:11
|
Re: Conditional block - when paramDoesn't work,
1- Here is the code, with "real" test on data for the third one, doomy test 1==1 and 1==0 on the first 2 to be sure it's not a problem with data. Moreover, the data is shown unconditionally to see the actual values...
2- And here the merged result on 2 records: Test_with_mail_and_tel Bob & Claire Commun: ok xxx ok xxx telCommun1: 234 Bob: xxx ok xxx 123: Tel_a_1 456: Tel_a_2 a@b.com b@c.com Claire: xxx ok xxx 234: Tel_b_1 567: Tel_b_2 Test_with_neither_tel_nor_mail & Commun: empty xxx empty xxx : xxx empty xxx : xxx empty xxx 3- Version: 3.7.0 for php4 Could this be a problem? ->I'm using this version because it's for a php4 OVH server, BUT I'M TESTING IT ON LOCALHOST WITH PHP5... I suppose there's php compatibility from php5 with older code. Thanks in advance |
|||
By: Skrol29
Date: 2011-10-07
Time: 10:23
|
Re: Conditional block - when paramHi,
TBS for PHP 4 is compatible with PHP 5 if you don't set error reporting level to STRICT. A knowed bug with TBS 3.7.0 for PHP 4 will also display a notice if the error reporting level includes Notices. So your problem does not come from this. Nevertheless, I see that your conditional section are embedded in a main section of the same block ([lg;block=begin]...[lg;block=end]). Embedded sections are not allowed (but with parameter "headergrp"), so the parameter "block" are simply ignored inside the main block. Thus your conditional sections are in fact not recognized as section by TBS. |
|||
By: Anonymous
Date: 2011-10-07
Time: 11:22
|
Re: Conditional block - when paramOops,
But if I use blocks one after another (and not embedded), I suppose it'll take the next record for each following block... Maybe I can treat my "blocks" as fields, extend their scope to the surrounding <li> with "comm=li" and hide them with a "magnet" argument? But then I need to have an empty string for the test instead of my values "ok" or "empty"... Or maybe there's a solution with an "if ... then..." argument? But I don't see in the manual smthg that would have as an effect : "if x==1 then merge value else hide surrounding li element". I'll have to do some tests to get the logic of it... Thanks |
|||
By: Skrol29
Date: 2011-10-07
Time: 11:34
|
Re: Conditional block - when param> But if I use blocks one after another (and not embedded), I suppose it'll take the next record for each following block...
Only normal sections are used as alternative sections. And since you have a normal parts before and after the conditional parts, that is true that you cannot use conditional section in this case. > Maybe I can treat my "blocks" as fields, extend their scope to the surrounding <li> with "comm=li" and hide them with a "magnet" argument? Yes. > But then I need to have an empty string for the test instead of my values "ok" or "empty"... Not if you use parameter "ope=mok" and "ope=mko". It's on purpose. http://www.tinybutstrong.com/manual.php#html_field_prm_ope |
|||
By: fpierrat
Date: 2011-10-07
Time: 14:15
|
Re: Conditional block - when paramYESSSSSS,
Thanks a lot, it's very simple in fact:
Works perfectly. Thanks again. PS. Is there a place to set a "Solved" tag anywhere in the forum subject? |
|||
By: Skrol29
Date: 2011-10-07
Time: 14:33
|
Re: Conditional block - when param> PS. Is there a place to set a "Solved" tag anywhere in the forum subject?
Not yet, but good suggestion. |