Categories > TinyButStrong general >

headergrp

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Lapa
Date: 2003-08-27
Time: 18:00

headergrp

Hi,

Cenario:
$access[0] =   array( "Tech" =>"Dial", "Severity" =>1, "count_Severity"=>1);
$access[1] =   array( "Tech" =>"Dial", "Severity" =>2, "count_Severity"=>2);
$access[2] =   array( "Tech" =>"Dial", "Severity" =>3, "count_Severity"=>16);
$access[3] =   array( "Tech" =>"DSL", "Severity" =>1, "count_Severity"=>2);

What I need is a table with
Tech,count_Severity_1,count_Severity_2,count_Severity_3
Dial,1,2,16
DSL,2

Like this:
      <table>
        <tr>
          <td>[acess.Tech;block=tr;headergrp=Tech]</td>
          <td>[acess.count_Severity;block=td;headergrp=Severity]</td>
        </tr>
      </table>
But it doesn't seems to work... Help appreciated!

10x a lot for this great class,
   Lapa
By: Skrol29
Date: 2003-08-30
Time: 00:47

Re: headergrp

Hi Lapa,

It doeas'nt work because the two blocks with the same name are nested.

But if you bounf the first block on td, then you will never have a new row for each new Tech value.

Here is a piece of template that should display the dta like you want.
<table>
  <tr>
  [acess;block=begin;headergrp=Tech]
  </tr>
  <tr>
    <td>[acess.Tech]</td>
        [acess;block=end]
    <td>[acess.count_Severity;block=td;headergrp=Severity]</td>
  </tr>   
</table>

Tell me if it's closed to what you want.
By: Lapa
Date: 2003-09-01
Time: 15:35

Re: headergrp

10x ... But still doesn't work...

PHP script:
require('include/tbs_class.php');

$struct = array (
        array ( 'Tech' => 'BE_VoIP', 'count_Severity' => 3, 'Severity' => 5),
        array ( 'Tech' => 'BE_VoIP', 'count_Severity' => 10, 'Severity' => 3),
        array ( 'Tech' => 'XMATE', 'count_Severity' => 10, 'Severity' => 4),
        array ( 'Tech' => 'XMATE', 'count_Severity' => 10, 'Severity' => 3),
);

var_dump($struct);

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate("templates/test.htm") ;
$TBS->MergeBlock("test", $struct) ;

$TBS->Show() ;

templates/test.htm
<html>
<head>
</head>

<body >

<table>
  <tr>
  [test;block=begin;headergrp=Tech]
  </tr>
  <tr>
    <td>[test.Tech]</td>
        [test;block=end]
    <td>[test.count_Severity;block=td;headergrp=Severity]</td>
  </tr>
</table>

</body>
</html>

Result:
array(4) {
  [0]=>
  array(3) {
    ["Tech"]=>
    string(7) "BE_VoIP"
    ["count_Severity"]=>
    int(3)
    ["Severity"]=>
    int(5)
  }
  [1]=>
  array(3) {
    ["Tech"]=>
    string(7) "BE_VoIP"
    ["count_Severity"]=>
    int(10)
    ["Severity"]=>
    int(3)
  }
  [2]=>
  array(3) {
    ["Tech"]=>
    string(5) "XMATE"
    ["count_Severity"]=>
    int(10)
    ["Severity"]=>
    int(4)
  }
  [3]=>
  array(3) {
    ["Tech"]=>
    string(5) "XMATE"
    ["count_Severity"]=>
    int(10)
    ["Severity"]=>
    int(3)
  }
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>

<body >

<table>
  <tr>
 
  </tr>
</table>

</body>
</html>

Weird...
The only way I solved this, was with %p% in the sql query... and a "static" template.
Like this:
        <tr>
          <td class=tech>BE_VoIP</td>
          <td class=tech>&nbsp;</td>
          <td class=tech_count_5><pre>[BE_VoIP.count_Severity;block=pre;p1=5]</pre></td>
          <td class=tech_count_4><pre>[BE_VoIP.count_Severity;block=pre;p1=4]</pre></td>
          <td class=tech_count_3><pre>[BE_VoIP.count_Severity;block=pre;p1=3]</pre></td>
          <td class=tech_count_0><pre>[BE_VoIP.count_Severity;block=pre;p1=0]</pre></td>
        </tr>
But like you can imagine... only works for sql query's...