コード例 #1
0
ファイル: productcats.php プロジェクト: lxthien/batdongsan
 function updatePosition()
 {
     $positionList = $this->input->post('positionList');
     $idList = $this->input->post('idList');
     $productCat = new productCat();
     for ($i = 0; $i < count($idList); $i++) {
         $productCat->where("id", $idList[$i]);
         $productCat->get();
         $productCat->position = $positionList[$i];
         $productCat->save();
         $productCat->clear();
     }
     redirect("admin/productcats/listAll/" . $this->input->post('parentId'));
 }
コード例 #2
0
ファイル: fgalleries.php プロジェクト: lxthien/batdongsan
 function productCat($level)
 {
     //level1 : category is root cat
     //load param from url
     $categoryUrl = $this->uri->segment($level);
     $viewMode = $this->uri->segment($level + 1, "") == "" ? "ma-tran" : $this->uri->segment($level + 1);
     $orderBy = $this->uri->segment($level + 2, "") == "" ? "moi-nhat" : $this->uri->segment($level + 2);
     $page = $this->uri->segment($level + 3, "") == "" ? "trang-1" : $this->uri->segment($level + 3);
     $dis['viewMode'] = $viewMode;
     $dis['orderBy'] = $orderBy;
     $dis['page'] = $page;
     //limit
     $limit = $viewMode == "ma-tran" ? 15 : 10;
     $offset = ($this->getPageNumber($page) - 1) * $limit;
     $productCat = new productCat();
     $productCat->where("url", $categoryUrl);
     $productCat->get();
     $dis['productCat'] = $productCat;
     $this->page_title = $productCat->seo_title;
     if ($this->getPageNumber($page) != 1) {
         $this->page_title .= '  - Trang ' . $this->getPageNumber($page);
     }
     $this->page_description = $productCat->seo_description . ' - Trang ' . $this->getPageNumber($page);
     $this->page_keyword = $productCat->seo_keyword;
     //build breadcum
     $dis['breadcum'] = $productCat->buildBreadCum();
     //get root id for hover main menu
     $rootId = $productCat->getRootId();
     if ($rootId == $this->config->item('catPhoneId')) {
         $this->menu_active = 'dien-thoai';
     } else {
         if ($rootId == $this->config->item('catTabletId')) {
             $this->menu_active = 'may-tinh-bang';
         } else {
             if (in_array($rootId, $this->config->item('allAccessoriesId'))) {
                 $this->menu_active = 'phu-kien';
             } else {
                 if ($rootId == $this->config->item('catUsedProduct')) {
                     $this->menu_active = "kho-may-cu";
                 } else {
                     $this->menu_active = 'san-pham-khac';
                 }
             }
         }
     }
     $product = $productCat->getAllProduct(array("active" => 1), $this->getOrderBy($orderBy), $this->getOrderDirection($orderBy), $offset, $limit);
     $dis['product'] = $product;
     //load all product to get the total
     $allProduct = $productCat->getAllProduct(array("active" => 1), $this->getOrderBy($orderBy), $this->getOrderDirection($orderBy));
     $total = $allProduct->result_count();
     $url = "";
     for ($i = 1; $i <= $level; $i++) {
         $url .= $this->uri->segment($i) . "/";
     }
     $dis['pageUrl'] = $url;
     $config['base_url'] = site_url($url . "/" . $viewMode . "/" . $orderBy . "/trang-");
     $config['total_rows'] = $total;
     $config['per_page'] = $limit;
     $config['use_page_numbers'] = TRUE;
     $config['uri_segment'] = $level + 3;
     $config['num_links'] = 3;
     $config['full_tag_open'] = '<span class="pagin">';
     $config['full_tag_close'] = "</span>";
     $config['first_link'] = FALSE;
     $config['first_tag_open'] = '';
     $config['first_tag_close'] = '';
     $config['last_link'] = FALSE;
     $config['last_tag_open'] = '';
     $config['last_tag_close'] = '';
     $config['next_link'] = '<img src="' . base_url() . 'images/pagination_next.png" />';
     $config['next_tag_open'] = '';
     $config['next_tag_close'] = '';
     $config['prev_link'] = '<img src="' . base_url() . 'images/pagination_pre.png" /';
     $config['prev_tag_open'] = '';
     $config['prev_tag_close'] = '';
     $config['num_tag_open'] = '';
     $config['num_tag_close'] = '';
     $config['cur_tag_open'] = '<span class="active">';
     $config['cur_tag_close'] = '</span>';
     $this->pagination->initialize($config);
     if ($viewMode == 'ma-tran') {
         $dis['view'] = 'product/product_grid';
     } else {
         $dis['view'] = 'product/product_list';
     }
     $productSaleOff = new product();
     $productSaleOff->where('active', 1);
     $productSaleOff->where('isSale', 1);
     $productSaleOff->order_by('id', 'desc');
     $productSaleOff->get_iterated(15);
     $dis['productSaleOff'] = $productSaleOff;
     $dis['base_url'] = base_url();
     $this->viewfront($dis);
 }