<?php
class CMS extends MY_Controller
{
    public $provinces;

    public function __construct()
    {
        parent::__construct();
        $this->load->Model("Common_Model");
        $this->load->Model("CMS_Model");
        // $this->provinces = $this->Common_Model->loadPrvinces();
        $this->load->library('session');
        if ($this->session->province == "") {
            $arrDefaultlocation = $this->Common_Model->loadDefaultPrvinces();
            $this->session->province = $arrDefaultlocation->id;
        }

        $this->load->helper('custom'); // custom_helper.php
    }

    public function loadPage()
    {
        $data = $this->data;

        if ($this->CMS_Model->fetchPage($this->uri->segment(1))) {

            // $data["provinces"] = $this->provinces;//Must present.
            $data["pageContent"] = $this->CMS_Model->fetchPage($this->uri->segment(1));

            $this->load->view("cms", $data);
        } else {
            show_404();
        }
    }
}
