0

I've the data structures as shown below

Array
(
    [0] => Array
        (
            [name] => dummy0
            [projects] => Array
                (
                    [project_names] => project0
                    [dates] => Array
                        (
                            [0] => 5
                            [1] => 11
                            [2] => 28
                        )

                )

        )

    [1] => Array
        (
            [name] => dummy1
            [projects] => Array
                (
                    [project_names] => project1
                    [dates] => Array
                        (
                            [0] => 10
                            [1] => 12
                            [2] => 28
                        )

                )

        )

)

I'ld like to get the output as following format

dummy0

   Project0  
    5
    11
    28

dummy1

  Project1
   10
   12
   28

I've used below snippet but didnt get the oupput as I excepted

                  [replies;block=begin;sub1=projects]

                      [replies_sub1.val;block=tr;sub1=dates]
                        [replies_sub1_sub1.val;block=td]

                  [replies;block=end;comm=text:p]

Any kind of help will be appreciated

Skrol29
  • 5,402
  • 1
  • 20
  • 25

1 Answers1

0

The problem is that your sub-data dates is actually under 2 levels of columns: projects/dates. And TBS does not support such data structure for the automatic sub-block.

The solution is to change your data structure in order to have it like this :

(
    [0] => Array
        (
            [name] => dummy0
            [dates] => Array
                (
                    [0] => 5
                    [1] => 11
                    [2] => 28
                )
            ....
        )
    ....    

If you cannot change the structure, you can simply use parameter ondata with a custom function that will create a new (virtual) column in your data.

PHP:

function f_ondata($BlockName,&$CurrRec,$RecNum) {
    $CurrRec['dates_z'] = $CurrRec['projects']['dates'];
}

HTML:

<div style="border: solid 1px red;">

    [replies;block=begin;sub1=dates_z;ondata=f_ondata]

    <table border="1">

      <tr>                
        <td>
            [replies.projects.project_names]
        </td>
        <td>&nbsp;</td>
      </tr>

      <tr>                
        <td>&nbsp;</td>
        <td>
            [replies_sub1.val;block=tr]
        </td>
      </tr>

    </table>

    <text:p> [replies;block=end;comm=text:p] </text:p>
<div>
Skrol29
  • 5,402
  • 1
  • 20
  • 25