<?php

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

class Home_content extends CI_Controller {

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

    function isLoggedIn() {
        $isLoggedIn = $this->session->userdata('isLoggedIn');
        if ($isLoggedIn == false) {
            $this->session->set_flashdata('message_red_password', 'LOGIN DULUUUU CUY !');
            redirect('admin/loginpage');
        }
    }

    private $table = 'home_content';
    private $control = 'admin/home_content';
    private $folder_view = 'super/content';
    private $pk = 'id';

    public function index() {
        $key['id'] = '1';
        $data = array(
            'data_home' => $this->model_app->getSelectedData($this->table, $key)
        );
        renderSuper("$this->folder_view/home_content", $data);
    }

    function simpanHomeContent() {
        $key['id'] = $this->input->post('id');
        $title = $this->input->post('title');
        $content = $this->input->post('content');
        $data = array(
            'content' => $content
        );
        $this->model_app->updateData($this->table, $data, $key);
        redirect($this->control);
    }

}

/* End of file home_content.php */
/* Location: ./application/controllers/home_content.php */