Welcome Guest, Not a member yet? Register   Sign In
(Hopefully) simple pagination problem
#1

[eluser]garethfoote[/eluser]
Hi,

Relative newbie to CI. This is hopefully something simple I'm missing. The pagination class page in the User Guide doesn't seem to go into much detail and I'm therefore a bit stuck as to why this problem is occuring:

Problem:
Pagination is working fine except for when I click page 2 and the next (offset) set of DB results is displayed the pagination still thinks it's on page 1 (The 1 has not become a link). Therefore I cannot click on the 1 returning me to the first set of results.
Example: http://ultravioletdesign.co.uk/mdi/adas_.../articles/

Here is the function in my controller:
Code:
function articles()
    {
        if($_POST){
            $date_filter = $this->input->post('dates');
            $category_filter = $this->input->post('category');
        } else {
            $date_filter = "all";
            $category_filter = "all";
        }
        
        $offset = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
        
        
        if(($date_filter == "all") && ($category_filter == "all")){
            $query = $this->Articles_select_model->get_all($this->no_of_displayed_items, $offset);
            $articles_list = $this->convert_query_to_array($query);
        }
    

        //echo $this->no_of_displayed_items . " / " . $this->db->count_all('article');
        $config = $this->pagination_setup($this->no_of_displayed_items, $this->db->count_all('article'));
        $this->pagination->initialize($config);
        
        //$this->display_filters($date_filter);
        $this->display_articles($articles_list); //this loads the view    
    }


    function display_articles($articles_list)
    {
        $article_data = array('articles' => $articles_list);
           $this->load->view("admin/articles_list", $article_data);
    }




Hope someone can shed some light on this. Please excuse any bad practices or un-elegant code. I'm learning best practices as I go along.

Many thanks,

Gareth
#2

[eluser]therealmaloy[/eluser]
@garethfoote


your pagination config may have lack the uri_segment

Code:
$config['uri_segment'] = 4;
#3

[eluser]garethfoote[/eluser]
Many thanks.

You're my hero!




Theme © iAndrew 2016 - Forum software by © MyBB