TinyButStrong PHP Templating multicolumn table -
i'm using tbs sample code:
include_once('tbs_class.php'); $tbs = new clstinybutstrong; $tbs->loadtemplate('template.htm'); $list = array('x','y','z'); $tbs->mergeblock('blk', $list); $tbs->show();
but instead of 1 column table below
<table> <tr><td>x</td></tr> <tr><td>y</td></tr> <tr><td>z</td></tr> </table>
i want multicolumn (for instance 4 column) table.
so far working code found is:
$number_of_columns = 4; $number_of_rows = 2; $number_of_items = $number_of_columns * $number_of_rows; $output_data = array('1', '2', '3', '4', '5', '6', '7', '8'); $tbs->mergeblock('col','num',$number_of_columns); // expand columns $tbs->mergeblock('od',array_slice($output_data,0,$number_of_items));
and template
<table border="1"> <tr>[od;block=tr;serial]<td>[od_[col.val;block=td].val;block=td]</td></tr> </table>
is there simpler?
if want display items sequentially this
1 2 3 4 5 6 7 8 9 10 11
then can :
1) use serial mode in tbs example. purpose of parameter , example quite simple.
2) change items in data source $output_data
, there 1 record per row.
script :
$data = array( array(1, 2, 3, 4), array(5, 6, 7, 8), array(9, 10, 11), ); $tbs->mergeblock('od', $data);
template :
<table> <tr> <td>[id.0;block=tr]</td> <td>[id.1;noerr]</td> <td>[id.2;noerr]</td> <td>[id.3;noerr]</td> </tr> </table>
3) don't change data, instead change html template. instead of table, use <div>
fixed width. in div, use entity positioned in line, such <span>
width is quarter of <div>
. each <span>
displayed sequentially line break each 4 <span>
.
$output_data = array('1', '2', '3', '4', '5', '6', '7', '8'); $tbs->mergeblock('od', $output_data);
Comments
Post a Comment