博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeigniter 3.0 相关文档 part two
阅读量:4678 次
发布时间:2019-06-09

本文共 2004 字,大约阅读时间需要 6 分钟。

分页

首先,配置

$this->load->library('pagination');        $config = array();        // $this->config->load('pagination');        $config["base_url"] = site_url('lift/index');        $config["total_rows"] = $this->Lift_model->record_count();        $config["per_page"] = 15;        $config["uri_segment"] = 3;        $config['use_page_numbers'] = TRUE;        $this->pagination->initialize($config);        $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 1;        $data["lm_lift"] = $this->Lift_model->get_lifts($config["per_page"], $page);        $data["links"] = $this->pagination->create_links();        $this->load->view('lift/index',$data);

前端输出

样式美化,这里以bootstrap pagination为例子,在config目录下添加pagination.php的配置

";$config['full_tag_close'] ="";$config['num_tag_open'] = '
  • ';$config['num_tag_close'] = '
  • ';$config['cur_tag_open'] = "
  • ";$config['cur_tag_close'] = "
  • ";$config['next_tag_open'] = "
  • ";$config['next_tagl_close'] = "
  • ";$config['prev_tag_open'] = "
  • ";$config['prev_tagl_close'] = "
  • ";$config['first_tag_open'] = "
  • ";$config['first_tagl_close'] = "
  • ";$config['last_tag_open'] = "
  • ";$config['last_tagl_close'] = "
  • ";// end of file Pagination.php // Location config/pagination.php // By @ mzhong

    分页保持查询条件

    http不能保持状态,可以通过session,uri来保持。如果要用uri来保持状态的话,就需要把查询表单修改为get提交方式。

    'get')); ?>

    需要用的配置项:

    $config['suffix'] = '';
    给路径添加一个自定义后缀,后缀位于偏移段的后面。

    $config["base_url"] = site_url('c/search');if (count($get) > 0) {      $config['suffix'] = '?' . http_build_query($get, '', "&"); }$config['first_url'] = site_url('c/search/1?') . http_build_query($get, '', "&query=true"); //修复第一页bug.是Pagination.php自作聪明地将第一页认为总是不必加分页号.

    防止静态文件被跳转

    RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-f #tells mod_rewrite ignore the url if it's an actual file, and RewriteCond %{REQUEST_FILENAME} !-d #tells it to ignore it if it's a directory.RewriteCond $1 !^(index\.php|contact\.php|images|css|js|video|robots\.txt)RewriteRule ^(.*)$ index.php/$1 [L]

    转载于:https://www.cnblogs.com/flowerszhong/p/6073356.html

    你可能感兴趣的文章
    简单的随机数 代码和笔记
    查看>>
    HTML5中x-webkit-speech语音输入功能
    查看>>
    class.forName的官方使用方法说明
    查看>>
    第9周表格
    查看>>
    用cxf创建webservice服务端
    查看>>
    Visual Studio 单元测试之三---压力测试
    查看>>
    【整理】windows service类型项目的开发。
    查看>>
    模式的秘密---代理模式
    查看>>
    jmeter之jtl文件解析
    查看>>
    selenium 标签页切换
    查看>>
    import configparser
    查看>>
    勇士闯迷宫
    查看>>
    mysql-冗余和重复索引
    查看>>
    backbone学习笔记0
    查看>>
    移动端调试 weinre
    查看>>
    JDK自带工具keytool生成ssl证书
    查看>>
    总结下抽象类Abstract和虚方法Virtual(易混点)
    查看>>
    CSUOJ 1248 非变性聚丙烯酰胺凝胶电泳
    查看>>
    POJ 2823 Sliding Window
    查看>>
    element-UI el-table二次封装
    查看>>