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 : /var/www/kamariallee.com/public_html/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') || exit('No direct script access allowed'); class Customize extends Public_Controller { public function __construct() { parent::__construct(); $this->load->model('product_m'); } public function get($alias_level1 = null, $alias_level2 = null) { if ($alias_level1 == null) { show_404(); } //get category level 1 detail $this->db->select('id_categories, category, image, title, description, meta_description') ->from('categories') ->where('alias', $alias_level1) ->where('parent', null); $category = $this->db->get()->row_array(); if(!$category) { show_404(); } //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()->products_displayed; //check if post sort_product is exist if ($this->input->post('sort_product')) { $this->session->set_userdata('sort_product', $this->input->post('sort_product')); } $this->data['level1_id'] = $category['id_categories']; $this->data['level1_category'] = $category['category']; $this->data['level1_alias'] = $alias_level1; $this->data['category_name'] = $category['category']; $this->data['banner_title'] = $category['title']; $this->data['banner_description'] = $category['description']; $this->data['banner_image'] = $category['image']; $this->data['sort_product_by'] = $this->session->userdata('sort_product'); //pagination $config = array(); $this->load->library('pagination'); $this->load->helper('pagination_helper'); $config = pagination_format(); $config['per_page'] = $per_page; if($alias_level1 == 'show-all') { $config['total_rows'] = $this->product_m->count_products_all(); $config['base_url'] = base_url() . 'customize/' . strtolower($alias_level1); $config['uri_segment'] = 3; $this->data['products'] = $this->product_m->get_products_all( $config['per_page'], $this->uri->segment($config['uri_segment'])); } elseif($alias_level1 != 'show-all') { if($alias_level2 && !is_numeric($alias_level2)) { $this->db->select('id_categories, category, title, description, image, meta_description') ->from('categories') ->where('alias', $alias_level2) ->where('parent', $category['id_categories']); $category = $this->db->get()->row_array(); if (!$category) { show_404(); } $this->data['level2_id'] = $category['id_categories']; $this->data['level2_category'] = $category['category']; $this->data['level2_alias'] = $alias_level2; $this->data['category_name'] = $category['category']; $this->data['banner_title'] = $category['title']; $this->data['banner_description'] = $category['description']; $this->data['banner_image'] = $category['image']; $config['base_url'] = base_url() . 'customize/' . strtolower($alias_level1) . '/' . strtolower($alias_level2); $config['total_rows'] = $this->product_m->count_products_by_category($category['id_categories']); $config['uri_segment'] = 4; $this->data['products'] = $this->product_m->get_products_by_category( $category['id_categories'], $config['per_page'], $this->uri->segment($config['uri_segment'])); } else { $config['total_rows'] = $this->product_m->count_products_by_category($category['id_categories']); $config['base_url'] = base_url() . 'customize/' . strtolower($alias_level1); $config['uri_segment'] = 3; $this->data['products'] = $this->product_m->get_products_by_category( $category['id_categories'], $config['per_page'], $this->uri->segment($config['uri_segment'])); } } $this->pagination->initialize($config); $this->data['total_products'] = $config['total_rows']; $this->data['alias_level1'] = $alias_level1; $this->data['alias_level2'] = $alias_level2; $this->load->helper('cms_helper'); //Get SEO $this->data_header['browser_title'] = 'Category - ' . ucwords($category['category']); $this->data_header['meta_description'] = $category['meta_description']; $this->load->view('template/header', $this->data_header); $this->load->view('customize', $this->data); $this->load->view('template/footer', $this->data_footer); //set current category to session, so it can be track to product page /* $this->session->set_userdata('current_viewed_category', $alias); */ } }