<?php 
	class Pages extends CI_Controller{

		/*public function view($page = 'home'){*/
		public function view($offset = 0){
			//echo "g"; exit;
			/*if (!file_exists(APPPATH.'views/pages/'.$page.'.php')) {
				show_404();
			}*/
			/*$data['title'] = ucfirst($page);
			$this->load->view('templates/header');
			$this->load->view('pages/'.$page, $data);
			$this->load->view('templates/footer');*/

			// Pagination Config
			$config['base_url'] = base_url();
			$config['total_rows'] = $this->db->count_all('posts');
			$config['per_page'] = 9;
			$config['uri_segment'] = 3;
			$config['attributes'] = array('class' => 'paginate-link');

			// Init Pagination
			$this->pagination->initialize($config);

			$data['title'] = 'Latest Book';

			$data['posts'] = $this->Post_Model->get_posts(FALSE, $config['per_page'], $offset);
			$data['posts_random'] = $this->Post_Model->get_posts_random(FALSE, 3, $offset);
			//echo "<pre>"; print_r($data['posts_random']); exit;

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

		public function cron($value='')
		{
			$data['posts'] = $this->Post_Model->cron_posts();
			echo "Done"; exit;
			//echo "<pre>"; print_r($data['posts']); exit;
		}
	}
	