Categories > TinyButStrong general >

Parent Group #?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: François
Date: 2005-11-29
Time: 15:23

Parent Group #?

I'm using the parentgrp function to split a list of results according to a column.
But I would like to display also the number of items in each groups.

A bit like this:

Group 1         3 items
  -blabla
  -blabla
  -blbla
Group 2         2 items
  -blabla
  -blabla

I can't find a way to do this simply, is there any solution? Thanks in advance!
By: Skrol29
Date: 2005-11-29
Time: 16:13

Re: Parent Group #?

Hello François,

The only way to do it for now is to use a "ondata" (or "onformat") custom function that does that counter.
It's not a big function.
By: François
Date: 2005-11-29
Time: 17:25

Re: Parent Group #?

Hi Skrol29. Thanks for your fast answer.
I have applied your solution with success.
For those wondering about the onformat custom function, here is my code:

$nb_items=0;
function display_nb($Fieldname,&$Currval)
    {
    global $nb_items;
    $Currval=$Currval-$nb_items;   
    $nb_items=$Currval;
    }

I simply declare a global var "nb_items", where I save the current item number. I place the [block.#;onformat=display_nb] as the footer of my block, it displays the number of items of my first group, save the value, then for each new group, display the total number of items - the saved nb_items value.