You've already forked codeigniter_test
first commit
This commit is contained in:
37
application/controllers/blog.php
Normal file
37
application/controllers/blog.php
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Blog extends CI_Controller{
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('M_post');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->load->model('M_post');
|
||||
$this->db->select('*');
|
||||
$this->db->from('post');
|
||||
$getData = $this->db->get('');
|
||||
$a = $getData->num_rows();
|
||||
$config['base_url'] = base_url().'/blog/index'; //set the base url for pagination
|
||||
$config['total_rows'] = $a; //total rows
|
||||
$config['per_page'] = '5'; //the number of per page for pagination
|
||||
$config['uri_segment'] = '3'; //see from base_url. 3 for this case
|
||||
$this->pagination->initialize($config);
|
||||
$data = array(
|
||||
'judul' => 'Another Web',
|
||||
'daftarpost' => $this->M_post->get_post_all($config['per_page'],$this->uri->segment(3))
|
||||
);
|
||||
$this->load->view('blog/vIndex',$data);
|
||||
}
|
||||
|
||||
function post($id)
|
||||
{
|
||||
$data['judul']='Page';
|
||||
$data['edit']=$this->M_post->edit_post($id);
|
||||
$this->load->view('blog/vSingle',$data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user