Topic: Pagination inside widgets |
|||
|---|---|---|---|
Posted: 2011-10-06 |
|||
|
User |
Hi, is there any way to use CI's pagination inside a widget? I've tried to do it (see code below) but when I click one of the links (http://domain.tld/particulares/12), I'm redirected to 404 The widget is inside a content page. This is my widget code public function run($options)
{
$this->load->model('articulos/product_m');
$category_id = $options['category_id'];
$this->load->library('pagination');
$config = array();
$config['base_url'] = current_url();
$config['total_rows'] = $this->product_m->count_all_by_category($category_id);
$config['per_page'] = 12;
$config['uri_segment'] = 2;
$this->pagination->initialize($config);
$offset = $this->uri->segment( $config['uri_segment'] );
$products = $this->product_m->get_all( $config['per_page'] , $offset , $category_id );
return array(
'products' => $products,
'pagination' => $this->pagination->create_links()
);
} |
||
| Quote | |||
Posted: 2011-10-08 |
# 1 | ||
|
Admin |
You cannot use pagination in a Widget, because a widget is just some data in a block on a page. A widget does not have multiple pages. You'll need to do this as a custom module instead. |
||
| Quote | |||
Posted: 2012-01-04 |
# 2 | ||
|
User |
You could use a jQuery UI plugin to 'fake' pagination within a widget. | ||
| Quote | |||
