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


class Bloglist extends CI_Controller {

    public $layout = 'full';
    public $module = 'blog_list_view';
    public $model = 'Blog_list_Model';

    public function __construct() {
        parent::__construct();
        // $this->load->model($this->model);
        // $this->_primary_key = $this->{$this->model}->_primary_keys[0];
        $this->load->model('Settings_Model','settings_model'); 
    }

    public function index() {

        $data=array();
        // $data['sliders'] = $this->db->get('sliders')->result();
        // $data['categories'] = $this->db->get('categories')->result();
        // $data['testimonials'] = $this->db->get('testimonials')->result();
        // $data['partners'] = $this->db->limit(6)->get('partners')->result();
        // $this->{$this->model}->order_by['project_id'] = 'DESC';
        // $this->{$this->model}->limit = 6;
        // $data['items'] = $this->{$this->model}->get();

        //load setting value
        $data['settings']= new stdClass;
        foreach ($this->settings_model->get() as $setting) {
            // echo "get setting";
            $data['settings']->{ $setting->key } = $setting->value;
            
        }
        //end load setting value

        //load main menu
        $this->load->model('Landingmain_Model','landingmain_model'); 
        $data['landingmain'] = $this->landingmain_model->get();    
        //end load main menu

        //load sub menu
        $this->load->model('Landingsubmenu_Model','landingsubmenu_model');
        $data['landingsubmenu'] = $this->landingsubmenu_model->get();
        //end load submenu


        //load content menu
        $this->load->model('Landingcontentmultistyle_Model','landingcontentmultistyle_model');
        $data['landingcontentmultistylemenu'] = $this->landingcontentmultistyle_model->get();
        //end　load content menu　

        //get blog tag content

        
        $this->load->model('Blog_tag_Model','blog_tag_model');
        $data['blogtagcontent'] = $this->blog_tag_model->get();
        //end get blog tag content


        //get blog content
        $this->load->model('Blog_list_Model','blog_list_model');
        $data['bloglistcontent'] = $this->blog_list_model->get();
        //end get blog content


       //echo    $displaypage;

        // var_dump($data['landingcontent']);   
        //end loading page content

        $this->load->view($this->module, $data);
    }
    public function detail($id){
        $data = [];

         $this->load->model('Blog_list_Model','blog_list_model');
        $data['bloglistcontent'] = $this->blog_list_model->get_id($id);
         $this->load->view('blog_list_detail_view', $data);

    }
   
    private function findpage($page){
    	$this->load->model('Blog_Model','blog_model'); 
        $id = $this->blog_model->findpage($page);   
        return $id;
    }
    private function verifyaccount(){

    }
    public function getView(){
        $this->load->model('Blog_list_Model','blog_list_model');

        $data['tag_id'] = $this->input->input_stream('tag', TRUE);
        $data['page'] = $this->input->input_stream('page', TRUE);
        $data['per'] = $this->input->input_stream('limit', TRUE) ? $this->input->input_stream('limit', TRUE) : 12;
        //var_dump($data);die;
        list($result['result'], $count) = $this->blog_list_model->getView($data);
        $result['count'] = ceil($count / $data['per']);
        
        $this->load->view('blog_square_view', $result);
    }
    
}

?>