Pagination

edited August 2012 in Modules
I'm experiencing very strange problem with pagination. I'm draging data from DB and setting paggination for it. But for some reason, the pagination's active page is not working at all, it is all the time set to the first page.
Here is my code:
//load the model
$this->load->model('shops_model');


// load pagination class
$this->load->library('pagination');

/* setting for the pagination */
$config['base_url'] = base_url().'/shop';
$config['total_rows'] = $this->shops_model->record_count();
$config['per_page'] = '3';
$config['first_link'] = '';
$config['last_link'] = '';
$config['use_page_numbers'] = false;
$config['page_query_string'] = FALSE;
$config['full_tag_open'] = '';
$config['full_tag_close'] = '';
$config['first_tag_open'] = '
';
$config['first_tag_close'] = '
';
$config['first_tag_open'] = '
';
$config['first_tag_close'] = '
';
$this->pagination->initialize($config);

$vars['pagination'] = $this->pagination->create_links();
$vars['items'] = $this->shops_model->find_all(null, 'id asc', $config['per_page'],$this->uri->segment(2));

// use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'shop/layout'));
$this->fuel_page->add_variables($vars);
$this->fuel_page->render();
}

Comments

  • edited 9:58PM
    For the $vars['items'], do you want $this->uri->segment(3) instead of $this->uri->segment(2)?
  • edited 9:58PM
    I think it should be segment2... it something like www.example.com/shop/3(this is the offset)
  • edited 9:58PM
    The strange thing that everything is working except the active pagination page is not getting marked
  • edited 9:58PM
    Are you using a route or something to get the shop/3 URI path?
  • edited 9:58PM
    no. I'm using the additional folder in fuel modules called "shop" which has controller shop.php
  • edited 9:58PM
    Are you using _remap on that controller? What if you add $config['uri_segment'] = 2;
  • edited 9:58PM
    yes, I do use remap. As well I'm using the controller from separated folder /fuel/modules/shop( this is custom made).
    How can you render fuel page and direct it to the separated module folder? In my case I would like to call views,models not the one which are located in application/views, but the one in fuel/modules/shop/views?
  • edited 9:58PM
    Try adding:
    public $view_location = "shop";
    to your controller before the contstructor.
Sign In or Register to comment.