Categories > TinyButStrong general >

conditional parentgroup

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SunWuKung
Date: 2007-10-05
Time: 17:17

conditional parentgroup

I would like the following parentgroup to generate output only if [irs.optionorder] is not empty but
- if I put
when [irs.optionorder]!=''
in the parentgroup block definition it stops behaving like a parentgroup and generates a new row for each value of itemid
- if I put
[irs.optionorder;magnet=tr]
anywhere it simply has no effect

Could somebody help me with this one?
Thx.
SWK

  <tr>
    <td>[irs;block=tr; parentgrp=itemid]</td>
    <td></td>
    <td>
    <select name="[irs.itemid]">
      <option value="[irs.optionorder]">[irs.optiontxt;block=option]</option>                      
    </select></td>
    </td>
  </tr>

By: Skrol29
Date: 2007-10-05
Time: 20:50

Re: conditional parentgroup

When (optionorder='') you want to display no rows at all, or you want to display rows but not grouping ?
By: Anonymous
Date: 2007-10-05
Time: 22:45

Re: conditional parentgroup

No rows at all.
I thought to place another conditional block below this for the case when there are no optionorders.

In real-life terms I am creating a form
- when I have options than this is a dropdown and I want to create and populate it
- when there are no options than it is a text field

I am struggling with the first point - to create and populate the dropdowns only when there are options.
By: SunWuKung
Date: 2007-10-09
Time: 16:40

Re: conditional parentgroup

I still cant find the solution to this one.
I thought to do two separate queries - but its a heavy query and it seems such a waste of time to do it twice when I already have all the info I need here.
Thanks for any help.
SWK
By: Skrol29
Date: 2007-10-10
Time: 00:44

Re: conditional parentgroup

Hi Sun,

Here is a solution which is working. But it is ugly...
<table border="1">
  <tr>
    <td>[irs;block=tr; parentgrp=itemid]</td>
    <td></td>
    <td>
      <select name="[irs.itemid]">
        <input value="[irs.optiontxt;block=input/;when '[irs.optionorder]'=='']" name="[irs.itemid]" [onshow;magnet=select;mtype=m+m]/>
        <option value="[irs.optionorder]">[irs.optiontxt;block=option;default]</option>
      </select>
    </td>
  </tr>
</table>

Your problem is difficult because the HTML grouping part should not be same when "optionorder" is empty or not.
By: SunWuKung
Date: 2007-10-12
Time: 10:28

Re: conditional parentgroup

Hi Skrol29,
it is working indeed - using onshow would have never occur to me.

It was surprising to see that if I put
when [irs.optionorder]!=''
in the parentgroup block definition it stops behaving like a parentgroup and generates a new row for each value instead of just each new value. I dont know if this is a bug or not.

But the problem is solved.
Thank you very much for the help.
SWK


By: Skrol29
Date: 2007-10-14
Time: 00:40

Re: conditional parentgroup

Yes I say that too.
You have to put quotes on both arguments. I'll check if it's a bug or if it has sense.