Welcome Guest, Not a member yet? Register   Sign In
Pagination and passing argument to the function
#1

[eluser]nahalem[/eluser]
Hay,

I have a seroius problem while creating pagination on page. Pagination is create well, link are showed but I'm passing one parameter to the function that shows my categories menu on the page. Thing is when I'm clicking second link of my pagination it doesn't work properly. Only first pagination link is active and it showing only first 4 products. Can you help me resolve that problem pls? Code below:

controller function:
Code:
public function polimaxCategories($arg)
{
  //$config['base_url'] = site_url('polimax/polimaxCategories');
  $config['base_url'] = site_url('polimax/polimaxCategories/'.$arg);
  //$config['base_url'] = base_url().'polimax/polimaxCategories/'.$arg.'/';
  $config['total_rows'] = $this->db->get('products')->num_rows();
  $config['per_page'] = 4;
  $config['num_links'] = 10;
        $config['uri_segment'] = 3;
  $config['full_tag_open'] = '<div id="pagination">';
  $config['full_tag_close'] = '</div>';
  
  $this->pagination->initialize($config);
              
  $this->load->model('cart_model');
        //
  $data['products'] = $this->cart_model->retrieveProductsOnPage($arg,$config['per_page'], $config['uri_segment']);
  
  $this->load->model('categories_model');
  $data['cat'] = $this->categories_model->retrieveActiveCategories();
  $data['content_cat'] = 'static/menu_categories';
  
  $data['content'] = 'cart/products';
  $this->load->view('polimax',$data);  
  
}

#2

[eluser]Aken[/eluser]
You probably need to change the uri_segment option, since your $arg is adding an additional segment to the URL.
#3

[eluser]nahalem[/eluser]
I'm using many various values of that option. First link of pagination is active, when I'm clicking second or third first is active and it's showing same data all the time...
Link when I mouseover on the seconf link is

polimaxCategories/1/4 - second link
polimaxCategories/1/8 - third link

first is $arg value second pagination page...
#4

[eluser]Aken[/eluser]
Your data never changes because you're passing the $config['uri_segment'] variable to your retrieve products method. That variable never changes, no matter what page you're viewing.
#5

[eluser]nahalem[/eluser]
I don't understand, on this tutorial uri is passed to the method http://godbit.com/article/pagination-with-code-igniter.

What I check is when I clicking on categories anchors then paginations links are changing all the time, something is wrong with passing parameter and pagination parameter using on my method. is someone has the same problem???
#6

[eluser]Aken[/eluser]
Your URI segment parameter for the retrieveProductsOnPage() method is wrong. Compare yours with that tutorial and you'll find out why.




Theme © iAndrew 2016 - Forum software by © MyBB