【问题标题】:url getting restarted when codeigniter pagination link is clicked单击codeigniter分页链接时,url会重新启动
【发布时间】:2013-02-01 22:40:51
【问题描述】:

我必须在“网格”视图或列表“视图”中显示产品信息。

最初我传递了一个类似http://localhost/thebestbookfinder.com/viewallbooks/books/pgn/1/grid 的网址,但是如果我点击分页链接,那么我的网址将重新启动到http://localhost/thebestbookfinder.com/viewallbooks/books/pgn/1。因此,因此我无法加载我的视图格式数据。 如何解决此错误?

这个疑问是我朋友问题的一部分Browse the main problem link

MyContoller.php

function books()
{
    $config = array();  
    $config['base_url'] = base_url().'viewallbooks/books/pgn/';
    $config["total_rows"] = $this->Booksmodel->record_count_for_secondtopBooks('3');
    $config['uri_segment'] = 4;
    $config['per_page'] = 3;
    $config['full_tag_open'] = '<div id="pagination">';
    $config['full_tag_close'] = '</div>'; 

       $this->pagination->initialize($config);
       $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;

    $data["query"] = $this->Subjectmodel->get_subjects();
    $data["query1"]=  $this->Editionmodel->get_edition(); 

    $data["query2"]=$this->Booksmodel->get_all_book_list_atHomeTop('3',$config["per_page"], $page);
     $data["links"] = $this->pagination->create_links();


   //---------For getting view type and passing to the view to show data accordingly-----
    $viewType = ($this->uri->segment(5)) ? $this->uri->segment(5) : 'list';
    $data["vt"]=$viewType;
    // ----Ends here For getting view type and passing to the view to show data accordingly-----

   $this->load->view('commonfiles/booksview',$data);   
}

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    将您的 base_url 更改为:

    $config['base_url'] = base_url().'viewallbooks/books/pgn/grid';
    

    并将您的 URL 结构更改为:

    http://localhost/thebestbookfinder.com/viewallbooks/books/pgn/grid/1

    页码应该是url中的最后一件事。

    【讨论】:

    • uri_segment 需要更改 5 对吗?喜欢$config['uri_segment'] = 5;
    • 用户可以再次通过单击链接 [grid view link] 或 [list view link] 从视图页面更改视图类型。因此,如果用户更改为“列表”视图并单击分页按钮,则视图类型应该是“列表”视图。这可能吗?
    • 是的,但是您需要修改函数头以首先包含列表类型,然后是页码。我在你的函数声明中没有看到这些。
    • 在哪里可以找到modify the function header
    猜你喜欢
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    • 2014-01-14
    • 2013-12-18
    • 2014-02-11
    • 2018-08-21
    • 2021-01-02
    相关资源
    最近更新 更多