当前位置: 首页>>代码示例>>PHP>>正文


PHP CI::Search方法代码示例

本文整理汇总了PHP中CI::Search方法的典型用法代码示例。如果您正苦于以下问题:PHP CI::Search方法的具体用法?PHP CI::Search怎么用?PHP CI::Search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CI的用法示例。


在下文中一共展示了CI::Search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index($code = false, $page = 0)
 {
     $pagination_base_url = site_url('search/' . $code);
     //how many products do we want to display per page?
     //this is configurable from the admin settings page.
     $per_page = config_item('products_per_page');
     \CI::load()->model('Search');
     //check to see if we have a search term
     if (!$code) {
         //if the term is in post, save it to the db and give me a reference
         $term = \CI::input()->post('term', true);
         if (empty($term)) {
             //if there is still no search term throw an error
             $data['error'] = lang('search_error');
             $this->view('search_error', $data);
             return;
         } else {
             $code = \CI::Search()->recordTerm($term);
             // no code? redirect so we can have the code in place for the sorting.
             // I know this isn't the best way...
             redirect('search/' . $code . '/' . $page);
         }
     } else {
         //if we have the md5 string, get the term
         $term = \CI::Search()->getTerm($code);
     }
     //fix for the category view page.
     $data['base_url'] = [];
     $sortArray = array('name/asc' => array('by' => 'name', 'sort' => 'ASC'), 'name/desc' => array('by' => 'name', 'sort' => 'DESC'), 'price/asc' => array('by' => 'price', 'sort' => 'ASC'), 'price/desc' => array('by' => 'price', 'sort' => 'DESC'));
     $sortBy = array('by' => false, 'sort' => false);
     if (isset($_GET['by'])) {
         if (isset($sortArray[$_GET['by']])) {
             $sortBy = $sortArray[$_GET['by']];
         }
     }
     if (empty($term)) {
         //if there is still no search term throw an error
         $this->view('search_error', $data);
         return;
     } else {
         $result = \CI::Products()->search_products($term, $per_page, $page, $sortBy['by'], $sortBy['sort']);
         $config['total_rows'] = $result['count'];
         \CI::load()->library('pagination');
         $config['base_url'] = $pagination_base_url;
         $config['uri_segment'] = 3;
         $config['per_page'] = $per_page;
         $config['num_links'] = 3;
         $config['total_rows'] = $result['count'];
         \CI::pagination()->initialize($config);
         $data['products'] = $result['products'];
         $data['category'] = (object) ['name' => str_replace('{term}', $term, lang('search_title'))];
         $this->view('categories/category', $data);
     }
 }
开发者ID:buzkall,项目名称:GoCart3,代码行数:54,代码来源:Search.php

示例2: index

 public function index($rows = 100, $order_by = "name", $sort_order = "ASC", $code = 0, $page = 0)
 {
     $data['groups'] = \CI::Customers()->get_groups();
     $data['page_title'] = lang('products');
     $data['code'] = $code;
     $term = false;
     $category_id = false;
     //get the category list for the drop menu
     $data['categories'] = \CI::Categories()->getCategoryOptionsMenu();
     $post = \CI::input()->post(null, false);
     \CI::load()->model('Search');
     if ($post) {
         $term = json_encode($post);
         $code = \CI::Search()->recordTerm($term);
         $data['code'] = $code;
     } elseif ($code) {
         $term = \CI::Search()->getTerm($code);
     }
     //store the search term
     $data['term'] = $term;
     $data['order_by'] = $order_by;
     $data['sort_order'] = $sort_order;
     $data['rows'] = $rows;
     $data['page'] = $page;
     $data['products'] = \CI::Products()->products(array('term' => $term, 'order_by' => $order_by, 'sort_order' => $sort_order, 'rows' => $rows, 'page' => $page));
     //total number of products
     $data['total'] = \CI::Products()->products(array('term' => $term, 'order_by' => $order_by, 'sort_order' => $sort_order), true);
     \CI::load()->library('pagination');
     $config['base_url'] = site_url('admin/products/' . $rows . '/' . $order_by . '/' . $sort_order . '/' . $code . '/');
     $config['total_rows'] = $data['total'];
     $config['per_page'] = $rows;
     $config['uri_segment'] = 7;
     $config['first_link'] = 'First';
     $config['first_tag_open'] = '<li>';
     $config['first_tag_close'] = '</li>';
     $config['last_link'] = 'Last';
     $config['last_tag_open'] = '<li>';
     $config['last_tag_close'] = '</li>';
     $config['full_tag_open'] = '<nav><ul class="pagination">';
     $config['full_tag_close'] = '</ul></nav>';
     $config['cur_tag_open'] = '<li class="active"><a href="#">';
     $config['cur_tag_close'] = '</a></li>';
     $config['num_tag_open'] = '<li>';
     $config['num_tag_close'] = '</li>';
     $config['prev_link'] = '&laquo;';
     $config['prev_tag_open'] = '<li>';
     $config['prev_tag_close'] = '</li>';
     $config['next_link'] = '&raquo;';
     $config['next_tag_open'] = '<li>';
     $config['next_tag_close'] = '</li>';
     \CI::pagination()->initialize($config);
     $this->view('products', $data);
 }
开发者ID:vandona,项目名称:v3,代码行数:53,代码来源:AdminProducts.php

示例3: index

 public function index($sort_by = 'order_number', $sort_order = 'desc', $code = 0, $page = 0, $rows = 100)
 {
     //if they submitted an export form do the export
     if (\CI::input()->post('submit') == 'export') {
         \CI::load()->model('Customers');
         \CI::load()->helper('download_helper');
         $post = \CI::input()->post(null, false);
         $term = (object) $post;
         $data['orders'] = \CI::Orders()->getOrders($term);
         foreach ($data['orders'] as &$o) {
             $o->items = \CI::Orders()->getItems($o->id);
         }
         force_download('orders.json', json_encode($data));
         return;
     }
     \CI::load()->helper('form');
     \CI::load()->helper('date');
     $data['message'] = \CI::session()->flashdata('message');
     $data['page_title'] = lang('orders');
     $data['code'] = $code;
     $term = false;
     $post = \CI::input()->post(null, false);
     if ($post) {
         //if the term is in post, save it to the db and give me a reference
         $term = json_encode($post);
         $code = \CI::Search()->recordTerm($term);
         $data['code'] = $code;
         //reset the term to an object for use
         $term = (object) $post;
     } elseif ($code) {
         $term = \CI::Search()->getTerm($code);
         $term = json_decode($term);
     }
     $data['term'] = $term;
     $data['orders'] = \CI::Orders()->getOrders($term, $sort_by, $sort_order, $rows, $page);
     $data['total'] = \CI::Orders()->getOrderCount($term);
     \CI::load()->library('pagination');
     $config['base_url'] = site_url('admin/orders/index/' . $sort_by . '/' . $sort_order . '/' . $code . '/');
     $config['total_rows'] = $data['total'];
     $config['per_page'] = $rows;
     $config['uri_segment'] = 7;
     $config['first_link'] = 'First';
     $config['first_tag_open'] = '<li>';
     $config['first_tag_close'] = '</li>';
     $config['last_link'] = 'Last';
     $config['last_tag_open'] = '<li>';
     $config['last_tag_close'] = '</li>';
     $config['full_tag_open'] = '<nav><ul class="pagination">';
     $config['full_tag_close'] = '</ul></nav>';
     $config['cur_tag_open'] = '<li class="active"><a href="#">';
     $config['cur_tag_close'] = '</a></li>';
     $config['num_tag_open'] = '<li>';
     $config['num_tag_close'] = '</li>';
     $config['prev_link'] = '&laquo;';
     $config['prev_tag_open'] = '<li>';
     $config['prev_tag_close'] = '</li>';
     $config['next_link'] = '&raquo;';
     $config['next_tag_open'] = '<li>';
     $config['next_tag_close'] = '</li>';
     \CI::pagination()->initialize($config);
     $data['sort_by'] = $sort_by;
     $data['sort_order'] = $sort_order;
     $this->view('orders', $data);
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:64,代码来源:AdminOrders.php


注:本文中的CI::Search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。