[英]Code Igniter Pagination and URL passed method arguments
My problem is that when I press on the pagination link the URL CHANGE and the segment array also so, first I started with this URL: 我的问题是,当我按下分页链接时,URL CHANGE和segment数组也是如此,首先,我从以下URL开始:
site/argument/argument
and when I press the pagination link the URL turn into: 当我按下分页链接时,URL变成:
site/method/startIndex.
Is there a way to use pagination without using the URL query index ? 有没有一种方法可以使用分页而不使用URL查询索引?
EDIT: 编辑:
Here is my controller method where I've receive the arguments from the URL: 这是我从URL接收参数的控制器方法:
function index ($par1, $par2 = null, $par3 = null)
{
$data['records'] = $this->site_model->getRecords($par1, $par2, $par3);
$this->load->view('main', $data);
}
And this is the Model method where I've do the DB query: 这是我执行数据库查询的Model方法:
function getRecords($par1, $par2 = null, $par3 = null )
{
if (!isset($par2) && !isset($par3)) {
$where = "lvlOne = '".$par1."'";
} elseif(isset($par2) && !isset($par3)) {
$where = "lvlOne = '".$par1."' AND lvlTwo = '".$par2."'";
} elseif(isset($par2) && isset($par3)) {
$where = "lvlOne = '".$par1."' AND lvlTwo = '".$par2."' AND lvlThree = '".$par3."'";
}
$this->db->from('mph_products');
$this->db->where($where);
$query = $this->db->get();
return $query->result();
}
How can I paginate this results? 我该如何对结果进行分页? Because I've got conflicts with the pagination library URL
因为我与分页库URL冲突
EDIT: 编辑:
I've found a way to do what I've wanted to. 我找到了一种可以做自己想做的方法。 There is a config option of the Pagination Library where you put the suffix of the pagination anchor and you can pass the arguments to it.
分页库中有一个配置选项,您可以在其中放置分页锚的后缀,然后可以将参数传递给它。
$config['suffix'] = "$arg1/$arg2/$arg3"; $ config ['suffix'] =“ $ arg1 / $ arg2 / $ arg3”;
:D :D
As I understand, you want not to see page number in url, but CI Pagination class always add number to link. 据我了解,您不希望在url中看到页码,但是CI分页类总是添加要链接的数字。 For more details see Pagination class .
有关更多详细信息,请参见分页类 。
Also you can use jquery datatable for client or server pagination. 您也可以将jquery数据表用于客户端或服务器分页。
This library codeigniter pagination + bootstrap design 该库的代码点火器分页+引导程序设计
<?php
class Paginacao
{
public $CI;
function __construct() {
$this->CI = &get_instance();
$this->CI->load->library('pagination');
}
function criar($total_rows,$base_url,$per_page=15,$num_links=5)
{
$paginacao['total_rows'] = $total_rows;
$paginacao['base_url'] = site_url($base_url);
$paginacao['per_page'] = $per_page;
$paginacao['num_links'] = $num_links;
$paginacao['full_tag_open'] = '<br /><div class="pagination pagination-centered"><ul>';
$paginacao['full_tag_close'] = '</ul></div>';
$paginacao['first_link'] = 'Primeira';
$paginacao['first_tag_open'] = '<li>';
$paginacao['first_tag_close'] = '<li>';
$paginacao['last_link'] = 'Ultima';
$paginacao['last_tag_open'] = '<li>';
$paginacao['last_tag_close'] = '</li>';
$paginacao['next_link'] = 'Próximo';
$paginacao['next_tag_open'] = '<li>';
$paginacao['next_tag_close'] = '</li>';
$paginacao['prev_link'] = 'Anterior';
$paginacao['prev_tag_open'] = '<li>';
$paginacao['prev_tag_close'] = '</li>';
$paginacao['cur_tag_open'] = '<li class="active"><a href="#">';
$paginacao['cur_tag_close'] = '</a></li>';
$paginacao['num_tag_open'] = '<li>';
$paginacao['num_tag_close'] = '</li>';
$this->CI->pagination->initialize($paginacao);
$html = $this->CI->pagination->create_links();
return $html;
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.