[eluser]BobyKurniawan[/eluser]
Hi, it's me again, now i want to ask about the url (I dont how to name it). I try to create my own CMS.
First, i already make a article just for a test, this how to see the list of my article via url bar
Code:
http://localhost/framecode/admin/artikel
admin controller
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin extends CI_Controller {
function artikel($offset=0)
{
$cek = $this->fc_model->cekaman();
if($cek!=null)
{
$x = $this->input->post('cari');
$field= array('judul'=> $x);
$data['include'] = 'admin/list_artikel';
$this->db->where('flag',1);
$this->db->like($field, $x);
$jml = $this->db->get('artikel');
$config['base_url'] = base_url().'admin/artikel';
$config['total_rows'] = $jml->num_rows();
$config['per_page'] = 5;
$config['first_page'] = 'Awal';
$config['last_page'] = 'Akhir';
$config['next_page'] = '«';
$config['prev_page'] = '»';
$this->pagination->initialize($config);
$data['halaman'] = $this->pagination->create_links();
$tbl='artikel';
$data['artikel'] = $this->fc_model->tampildata2($config['per_page'], $offset,$tbl,$x,$field);
$this->load->view('admin/page',$data);
}
else
{
redirect('login','refresh');
}
}
}
Then the lists of my articles will show up, now i want to see the article so i make a other controller like this ->
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class View extends CI_Controller {
function artikelview($id)
{
$sql = "select * from artikel where slug='$id'";
$data['artikel'] = $this->fc_model->tampildata($sql);
$this->load->view('home',$data);
}
}
this is the link from my view
Code:
<td class="action" ><a class="view">slug;?>">View</a><a class="edit">idartikel;?>">Edit</a> <a class="delete">idartikel;?>">Delete </a></td>
well it's work when i click 'view' from the link. Then my url bar change to this
Code:
http://localhost/framecode/view/artikel/tes-new-cat
The problem is, if i chaenge 'tes-new-cat' to -> 'sdasad', this message is show up
Message: Trying to get property of non-object
sorry for very bad english