[eluser]Unknown[/eluser]
hallo,
i newbie in codeigniter
and i want to display slug by id.
but its not working.
this is code in controller
function view($slug)
{
$this->data['halaman'] = $this->mhalaman->get_profil($slug);
if (empty($data['halaman'])) {
show_404();
}
$data['title'] = $data['halaman']['judul'];
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
$this->data['contents'] = $this->load->view('mahasiswa/profil/sejarah', $this->data, true);
$this->load->view('template/wrapper/admin/wrapper_ukm',$this->data);
}
this is code in modal
function get_profil($slug = FALSE)
{
if ($slug === FALSE)
{
$query = $this->db->get($this->tbl_halaman);
return $query->result_array();
}
$query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
return $query->row_array();
}
this is code in view header
<div class="section ui dropdown link item">
<span class="count">Profil</span>
<div class="menu">
<?php foreach ($halaman as $dt): ?>
<div class="item">
<a href="profil/<?php echo $dt['slug'] ?>"><?php echo $dt['judul'] ?></a>
</div>
<?php endforeach ?>
</div>
</div>
and this is code view content
<div id="content" class="clearfix">
<?php foreach ($halaman as $dt): ?>
<h2><?php echo $dt['judul'] ?></h2>
<p><?php echo $dt['content'] ?></p>
<?php endforeach ?>
please help me what to do. thank you.