|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /proc/self/root/var/www/symphony-solusi.co.id/public_html/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Category extends Public_Controller {
public function __construct() {
parent::__construct();
$this->session->set_userdata('site_lang','indonesian');
}
public function get($alias_level1 = NULL, $alias_level2 = NULL, $alias_level3 = NULL) {
if ($alias_level1 == NULL) { show_404(); }
if ($alias_level1 !== NULL && $alias_level1 != 'all-categories') {
//check if this category alias exist
$this->db->select('id_categories')->from('categories')->where('alias', $alias_level1)->where('parent', NULL)->where('status', 1);
$count_category = $this->db->get()->num_rows();
if ($count_category == 0) {
//category not exist in indonesian alias. So check to english
$this->db->select('id_categories')->from('categories')->where('alias_en', $alias_level1)->where('status', 1);
$count_category_en = $this->db->get()->num_rows();
if($count_category_en == 0) {
show_404();
} else {
//category exist in english. get category parameter
$this->db->select('*')->from('categories')->where('alias_en', $alias_level1);
$level1 = $this->db->get()->row();
$this->data['level1_id'] = $level1->id_categories;
$this->data['level1_title'] = $level1->category_en;
$this->data['level1_alias'] = $alias_level1;
//change the website session language to english
$this->session->set_userdata('site_lang', 'english');
$this->load->helper('language');
$this->lang->load('website','english');
}
} else {
//category exist for indonesian
$this->db->select('*')->from('categories')->where('alias', $alias_level1);
$level1 = $this->db->get()->row();
$this->data['level1_id'] = $level1->id_categories;
$this->data['level1_title'] = $level1->category;
$this->data['level1_alias'] = $alias_level1;
//change the website session language to indonesian
$this->session->set_userdata('site_lang', 'indonesian');
$this->load->helper('language');
$this->lang->load('website','indonesian');
}
}
//Load model product_m
$this->load->model('product_m');
//get no. of products per page (pagination) from configuration table
$this->db->select('products_displayed')->from('configuration')->where('id_configuration', 1);
$per_page = $this->db->get()->row();
//user request level 1 category
if ($alias_level1 != NULL && $alias_level1 != 'all-categories') {
//get category parameters
$this->db->select('*')->from('categories')->where('id_categories', (int) $level1->id_categories)->where('parent', NULL);
$this->data['category'] = $this->db->get()->row();
//check if post sort_product is exist
if ($this->input->post('sort_product')) {
$this->session->set_userdata('sort_product', $this->input->post('sort_product'));
}
//PRODUCTS
//pagination in action
$this->load->library('pagination');
$config = array();
$this->load->helper('pagination_helper');
$config = pagination_format();
$config['base_url'] = base_url() . 'category/' . $alias_level1 . '/';
$config['total_rows'] = $this->product_m->count_products_by_category($this->data['category']->id_categories);
$config['per_page'] = $per_page->products_displayed;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$this->data['sort_product_by'] = $this->session->userdata('sort_product');
$this->data['sidebanner_active_category_id'] = $this->data['level1_id'];
$this->data['total_products'] = $config['total_rows'];
$this->data['products'] = $this->product_m->get_products_by_category($this->data['category']->id_categories, $config['per_page'], $this->uri->segment($config['uri_segment']));
}
//get SEO
$this->data_header['browser_title'] = 'Category - ' . ucwords(str_replace('-', ' ', $alias_level1));
$this->data_header['meta_description'] = $this->data['category']->meta_description;
$this->data_header['meta_keywords'] = $this->data['category']->meta_keywords;
$this->load->helper('product');
$this->data['page'] = $this->db->select('category_landingpage_image as landingpage_image, category_landingpage_link as landingpage_title')->from('configuration')->where('id_configuration',1)->get()->row();
$this->lang->load('product_list', 'indonesian');
$this->data['products'] = $this->db->select('*')->from('products')->join('category_product','products.id_products=category_product.id_product')->join('categories','category_product.id_category=categories.id_categories')->where('categories.alias',$alias_level1)->where('products.product_status',1)->order_by('products.priority','ASC')->get()->result();
$this->load->view('template/header', $this->data_header);
$this->load->view('product', $this->data);
$this->load->view('template/footer', $this->data_footer);
}
}