【问题标题】:how do i show the page numbers in GET format with ? in codeigniter如何以 GET 格式显示页码?在代码点火器中
【发布时间】:2020-02-25 07:38:36
【问题描述】:

我有一个困难,我认为必须有一个非常简单的答案。 我正在为我的项目使用 CodeIgniter,并且我正在使用 pagination 来显示帖子的页码

代码

$this->load->library('pagination');
        if (count($_GET) > 0) $config['suffix'] = '?' . http_build_query($_GET, '', "&");
        $config['base_url'] = base_url('index.php/main/bloggers');
        $config['total_rows'] = $total_num;
        $config['per_page'] = $rec_per_page;
        $config['num_links'] = 10;
        $config['use_page_numbers'] = TRUE;
        $config['reuse_query_string'] = false;
        $config['full_tag_open'] = "<span class='page_num'>";
        $config['full_tag_close'] = '</span>';
        $this->pagination->initialize($config);

这段代码向我显示了这样的网址

domain.com/index.php/main/blogger/**2**

其中2是好的页码

当前网址是这样的

domain.com/index.php/main/blogger/**2**

所需的网址是

domain.com/index.php/main/blogger?**page=2**

问题:我想要的是我希望页码以 GET 类型的变量出现,这样我就可以使用 GET 并像使用段一样获取页面的值我不确定可能有有时也有其他值。

感谢任何帮助。

【问题讨论】:

    标签: php codeigniter codeigniter-3


    【解决方案1】:

    您需要在分页配置数组上设置以下选项:

    // Set the pagination to use the get parameter
    $config['page_query_string'] = TRUE;
    
    // Set the name of the get paramater
    $config['query_string_segment'] = 'page';
    

    【讨论】:

      猜你喜欢
      • 2011-12-18
      • 2011-07-07
      • 1970-01-01
      • 1970-01-01
      • 2012-03-27
      • 1970-01-01
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多