Membuat View | Chupoo Framework

Data Tunggal

Kode di kontroller

return function() {
$nama = 'Budi';
$alamat = 'Samarinda';

return $this->view(array(
'nama' => $nama,
'alamat' => $alamat
));
}

 Kode di view

<h1>Detail Siswa Peserta</h1>
<table>
<tr>
<th>Nama</th>
<td c.nama></td>
</tr>
<tr>
<th>Alamat</th>
<td c.alamat></td>
</tr>
</table>

Data Majemuk

Kode di kontroller

return function() {
$siswa_peserta = array(
array(
'no' => 1,
'nama' => 'Budi',
'alamat' => 'Samarinda'
),
array(
'no' => 2,
'nama' => 'Andi',
'alamat' => 'Makassar',
),
array(
'no' => 3,
'nama' => 'Ratna',
'alamat' => 'Jakarta'
)
);

return $this->view(array(
'siswa_peserta' => $siswa_peserta,
));
}

 Kode di view

<h1>Daftar Siswa Peserta</h2>
<table border="1">
<tr>
<th>No.</th>
<th>Nama</th>
<th>Alamat</th>
</tr>
<tr c.siswa_peserta>
<td c.no></td>
<td c.nama></td>
<td c.alamat></td>
</tr>
</table>