Skip to content

Instantly share code, notes, and snippets.

@cwicaksono
Created January 20, 2020 05:46
Show Gist options
  • Save cwicaksono/1025d3c22520a687fb0eb2cb6553b5f1 to your computer and use it in GitHub Desktop.
Save cwicaksono/1025d3c22520a687fb0eb2cb6553b5f1 to your computer and use it in GitHub Desktop.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('blogpost_model');
$this->load->model('categories_model');
}
public function index()
{
$data = array(
'posts' => $this->blogpost_model->getHome(),
'categories' => $this->categories_model->getAll()
);
$this->load->view('blog', $data);
}
public function view($id)
{
$this->db->join('users', 'users.id = blogpost.id_author');
$detail = $this->db->get_where('blogpost', array('blogpost.id' => $id))->result();
$data = array(
'detail' => $detail,
'categories' => $this->categories_model->getAll()
);
$this->load->view('detail', $data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment