4

我尝试在同一视图中的 codeigniter 中使用多个分页。我的控制器是:

    public function gallery()
{

    $config1 = array();
    $config1["base_url"] = site_url("pages/gallery");
    $config1["total_rows"] = $this->pagination_model->video_count();
    $config1["per_page"] = 1;
    $config1["uri_segment"] = 3;

    $this->pagination->initialize($config1);

    $page1 = ($this->uri->segment(3,0)) ? $this->uri->segment(3,0) : 0;
    $data["videos"] = $this->pagination_model->fetch_video($config1["per_page"], $page);
    $data["links1"] = $this->pagination->create_links();

    $config2 = array();
    $config2["base_url"] = site_url("pages/gallery").'/'.$this->uri->segment(3,0);
    $config2["total_rows"] = $this->pagination_model->gallery_count();
    $config2["per_page"] = 3;
    $config2["uri_segment"] = 4;

    $this->pagination->initialize($config2);

    $page2 = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
    $data["galleries"] = $this->pagination_model->fetch_gallery($config2["per_page"], $page2);
    $data["links2"] = $this->pagination->create_links();

    $this->template->gallery_view($data);
}

分页在第一个和第二个配置上工作正常,独立,但是当我点击页面 nr。3例如。在分页链接 2 上的分页链接 1 中转到 nr。3(只有页面编号内容是好的),并且在第 6 页链接 1 但链接 2 以 +1 递增。

需要按一下链接1:

  • 链接1 ------------ 链接2

    1 ----curent_page_link2(默认是link2 = '')

    2 ---- 当前页面链接2

    3 ---- 当前页面链接2

    3 ---- 当前页面链接2

但我点击链接1:

  • 链接1 ---------- 链接2

    1 ----curent_page_link2(默认是link2 = '')

    2 ----curent_page_link2(默认是link2 = '')

    3 ----curent_page_link2 (需要(默认为link2 ='')但我有来自link2 =''的activ link2 ='2'内容)

    4 ---- current_page_link2

    5 ----curent_page_link2 (需要(默认为link2 ='')但我有来自link2 =''的activ link2 ='3'内容)

对不起我的英语不好。

4

1 回答 1

1

我没有对此进行测试。这可能会对您有所帮助。在 config1 中使用“前缀”和“后缀”进行分页。

...

$config1 = array();
$config1["base_url"] = site_url("pages/gallery");
$config1["total_rows"] = $this->pagination_model->video_count();
$config1["per_page"] = 1;
$config1["uri_segment"] = 3;

////////////////////////////////////////////////////////

$config1['prefix'] = '';
$config1['suffix'] = '/'.$this->uri->segment(4,0);

////////////////////////////////////////////////////////

$this->pagination->initialize($config1);

...
于 2013-03-07T05:54:59.727 回答