user1721196
user1721196

Reputation:

url getting restarted when codeigniter pagination link is clicked

i have to display product info either in "grid" view or by list "view".

Intially i am passing a url like http://localhost/thebestbookfinder.com/viewallbooks/books/pgn/1/grid but if i click on the pagination links then my url is getting restarted to http://localhost/thebestbookfinder.com/viewallbooks/books/pgn/1 . Thus, because of this i am unable to load my view format data. How to fix this error?

This doubt is part of my friend problem 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);   
}

Upvotes: 1

Views: 688

Answers (1)

Samer Bechara
Samer Bechara

Reputation: 2109

Change your base_url to:

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

and change your URL structure to:

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

The page number should be the last thing in the url.

Upvotes: 2

Related Questions