<?php if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class Cmtv extends MY_Controller
{

    public function __construct()
    {
        echo '<script>history.back()</script>';
        die('준비중입니다.');
        parent::__construct();
        $this->load->model('post_model', 'post');
    }

    public function index()
    {
        $totSegments = $this->uri->total_segments();
        if (!is_numeric($this->uri->segment($totSegments))) {
            $pageURL = $this->uri->segment($totSegments);
        } elseif (is_numeric($this->uri->segment($totSegments))) {
            $pageURL = $this->uri->segment($totSegments - 1);
        }
        if ($pageURL == "") {
            $pageURL = "home";
        }
        $this->data['page'] = $this->page_model->getOne($pageURL);
        $this->data['postGroup'] = [];
        $recentUpdatedPosts = $this->db->where('categoryID', 30022)->get('cm_page_attributes')->result();
        foreach ($recentUpdatedPosts as $p) {
            array_push($this->data['postGroup'], $this->post->getPagePostsByPageId($p->pageID, 4));
        }
        $this->data['header'] = $this->load->view('templates/others/header', $this->data, true);
        $this->data['footer'] = $this->load->view('templates/others/footer', '', true);
        $this->load->view('templates/others/prayer', $this->data);
    }
}
