Esempio n. 1
0
 private function tpllist($thiscategory)
 {
     $tmpCategory = $this->Data_model->getData(array('model' => $thiscategory['model'], 'lang' => $this->Cache_model->currentLang, 'lft >=' => $thiscategory['lft'], 'lft <' => $thiscategory['rht']), '', 0, 0, 'category');
     $categoryidarr = mult_to_idarr($tmpCategory);
     $datawhere = array('category' => $categoryidarr, 'puttime <' => time(), 'status' => 1, 'lang' => $this->Cache_model->currentLang);
     $currentpage = intval($this->uri->segment(3));
     $currentpage = $currentpage ? $currentpage : 1;
     $totalnum = $this->Data_model->getDataNum($datawhere, $thiscategory['model']);
     $this->load->library('pagination');
     $pageconfig['base_url'] = site_url('category/' . $thiscategory['dir']);
     $pageconfig['total_rows'] = $totalnum;
     $pageconfig['per_page'] = $thiscategory['pagesize'] > 0 ? $thiscategory['pagesize'] : 20;
     $pageconfig['uri_segment'] = 3;
     $pageconfig['langurl'] = $this->Cache_model->langurl;
     $this->pagination->initialize($pageconfig);
     $list = $this->Data_model->getData($datawhere, 'listorder,puttime desc', $pageconfig['per_page'], ($currentpage - 1) * $pageconfig['per_page'], $thiscategory['model']);
     $config = $this->Cache_model->loadConfig();
     $config['seo_title'] = $thiscategory['title'] == '' ? $thiscategory['name'] : $thiscategory['title'];
     $config['seo_keywords'] = $thiscategory['keywords'] == '' ? $thiscategory['name'] : $thiscategory['keywords'];
     $config['seo_description'] = $thiscategory['description'] == '' ? '' : $thiscategory['description'];
     $this->load->setPath();
     $res = array('config' => $config, 'langurl' => $this->Cache_model->langurl, 'list' => $this->Cache_model->handleModelData($list), 'pagestr' => $this->pagination->create_links(), 'category' => $thiscategory);
     $tpl = $thiscategory['tpllist'] == '' ? $thiscategory['model'] . '_list' : $thiscategory['tpllist'];
     $this->load->view($config['site_template'] . '/' . $tpl, $res);
 }
Esempio n. 2
0
 function loadModel($model, $categoryid, $order, $num, $recommend)
 {
     $cachestr = $model . '_' . $this->currentLang . '_' . $categoryid . '_' . $order . '_' . $num . '_' . $recommend;
     $cache = $this->CI->cache->get($cachestr);
     if (!$cache) {
         $datawhere = array('status' => 1, 'lang' => $this->currentLang);
         if ($recommend) {
             $datawhere['recommends'] = '';
         }
         if ($categoryid > 0) {
             $row = $this->CI->Data_model->getSingle(array('id' => $categoryid), 'category');
             $tmpCategory = $this->CI->Data_model->getData(array('model' => $model, 'lang' => $this->currentLang, 'lft >=' => $row['lft'], 'rht <= ' => $row['rht']), '', 0, 0, 'category');
             $categoryidarr = mult_to_idarr($tmpCategory);
             $datawhere['category'] = $categoryidarr;
         }
         $orderstr = '';
         switch ($order) {
             case 'puttime':
                 $oderstr = 'puttime desc';
                 break;
             case 'hits':
                 $oderstr = 'hits desc';
                 break;
             case 'id':
                 $oderstr = 'id desc';
                 break;
             default:
                 $orderstr = 'listorder,id desc';
                 break;
         }
         $data = $this->CI->Data_model->getData($datawhere, $orderstr, $num, 0, $model);
         $cache = $this->handleModelData($data);
         $this->CI->cache->save($cachestr, $cache, 86400);
     }
     return $cache;
 }