Categories > TinyButStrong general >

Row count for subblocks

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: minimalist
Date: 2006-03-25
Time: 09:07

Row count for subblocks

Hi,

Could you tell me please, how to get the row count for a subblock? The standard form [block.#] doesn't work, because if it outside of the block definition, the field is doesn't merged.

For example, from tbs_us_examples_subblock.htm, I've added that 'Row count:' line, where I'd like to know how many rows are there in the subblock 'sb', and unfortunately [sb.#] doesn't merge.

...
<table width="400" border="1" align="center" cellpadding="4" cellspacing="0" bor  <tr>
    <td><strong>Team:</strong> [mb.team;block=tr]<br>
      <strong>Total score:</strong> [mb.total]<br>
<strong>Row count:</strong> [sb.#]<br>
      <br>
...
        <tr bgcolor="#F0F0F0">
          <td>[sb.#]</td>
          <td>[sb.town;block=tr;p1=[mb.$]]</td>
          <td><div align="right">[sb.score]</div></td>
          <td><div align="center">[sb.date;frm='mm-dd-yyyy']</div></td>
        </tr>
...

Greets & thanks in advance,
  minimalist
By: TomH
Date: 2006-03-25
Time: 14:25

Re: Row count for subblocks

Simply use an ondata function approach in the block - make a new globval var that can be used anywhere
Ref http://www.tinybutstrong.com/forum.php?msg_id=4819
By: minimalist
Date: 2006-03-25
Time: 19:13

Re: Row count for subblocks

Thank you TomH,

I did so and created these. The first function is the ondata function, the second one returns the row count for the correspondent block (for example: [f_getrowcount;id=[sub.id]]). Rather circumstancial, but I will improve it.

function f_rowcount($BlockName, &$CurrRec, $RecNum)
{
        global $rc;
        $rc[$CurrRec["id"]] = $RecNum;
}

function f_getrowcount($id_label, &$PrmLst)
{
        global $rc;
        return $rc[$PrmLst["id"]];
}