<?php
class Galeri extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->model('m_galeri');
		$this->load->model('m_album');
		$this->load->model('m_pengunjung');
		$this->m_pengunjung->count_visitor();
	}
	function index(){
		$x['alb']=$this->m_album->get_all_album();
		$x['all_galeri']=$this->m_galeri->get_all_galeri();
		
		// Pastikan data terkirim ke view
		// Jika tidak ada data, tetap kirim object kosong agar tidak error
		if(!$x['all_galeri']) {
			$x['all_galeri'] = $this->db->query("SELECT * FROM tbl_galeri WHERE 1=0");
		}
		
		$this->load->view('depan/v_galeri',$x);
	}
	function album(){
		$idalbum=$this->uri->segment(3);
		$x['alb']=$this->m_album->get_all_album();
		$x['data']=$this->m_galeri->get_galeri_by_album_id($idalbum);
		$this->load->view('depan/v_galeri_per_album',$x);
	}
}
