Тема: Как сделать пагинацию в кастомном модуле?
День добрый!
Нужна помощь, не могу разобраться как сделать пагинацию в своем компоненте.
Вот что наработал
public function getAllEvents($category_url){
/* $offset = (int) $this->uri->segment(6);
$row_count = 20;*/
$query = $this->getListEvents(1, 3);
if (count($query)) {
$this->load->library('Pagination');
$config['base_url'] = site_url($category_url);
$config['total_rows'] =count($this->getListEvents()) ;
$config['per_page'] = 1;
$config['uri_segment'] = $this->uri->total_segments();
$this->pagination->num_links = 5;
$this->pagination->initialize($config);
$this->template->assign('pagination', $this->pagination->create_links_ajax());
// End pagination
}
\CMSFactory\assetManager::create()
->setData('eventsForDate', $query);
}
public function getListEvents($num =0, $offset = 0){
$this->db->select('mod_subscribes_event.title event_title, mod_subscribes_event.date event_date, mod_subscribes_event.img event_img, mod_subscribes_event.price event_price, mod_subscribes_event.status event_status, content.cat_url content_cat_url, content.url content_url');
$this->db->from('content');
$this->db->join('mod_subscribes_event', 'mod_subscribes_event.link_page_full = content.id');
$this->db->order_by("event_date", "desc");
$query = $this->db->get($this->table, $num, $offset);
$event_row = $query->result_array();
if ($this->db->_error_message()) {
throw new Exception($this->db->_error_message());
}
$eventsForDate = [];
foreach ($event_row as $event){
$date = date("Y-m-d", strtotime($event['event_date']));
$eventsForDate[$date][] = $event;
}
return $eventsForDate;
}
помогите разобраться?