CodeIgniter HTML generator with custom layout inside

CI table->generate($data1, $data2, $data3)will output my data in the form of a simple table , for example:

<table>
    <tr>
        <td>data1</td>
        <td>data2</td>
        <td>data3</td>
    </tr>
</table>

What if I need a complex layout of cells with several $varsin each cell:

$data1 = array('one', 'two', 'three'); 

and I want something like this:

<table>
    <tr>
        <td>
            <div class="caption">$data1[0]</div>
            <span class="span1">$data1[1] and here goes <strong>$data1[2]</strong></span>
        </td>
        <td>...</td>
        <td>...</td>
    </tr>
</table>

How do I encode this part?

Now I just create the content tdin the model and then call generate(). But this means that my HTML for the cell is in the model, but I would like to leave it in the form.

+3
source share
2 answers

, , , td. . , .

+2

Hailwood - . html table add_row. :

$row = array();
$row[] = array('data' => "<div class='caption'>{$data1[0]}</div><span class='span1'>{$data1[1]} and here goes <strong>{$data1[2]}</strong></span>");
$row[] = $col2;
$row[] = $col3;

$this->table->add_row($row)
echo $this->table->generate();

, caption , .

0

All Articles