<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Posts extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('post_model');
    }


	public function index() {
		//$this->output->enable_profiler(TRUE);
		$data['posts'] = $this->post_model->get_all();

		$this->load->view('templates/posts', $data);
	}


	public function view($id = NULL) {
		$data['post'] = $this->post_model->get_post_by('id', $id);

		if (empty($data['post'])) {
			show_404();
		}

		$this->load->view('templates/post_view', $data);
	}

}