2013-09-10 3 views
0

Что я сейчас, как 100 дивы стилизованных быть 4 в ряд, хотите добавить нумерацию страниц к нему, и я преуспел с этим кодом:CodeIgniter пагинация без таблиц

public function func() { 
     $this->load->library('pagination'); 
     $this->load->database('default'); 
     $this->load->model('s_model'); 

     $data['all_rows_s'] = $this->s_model->count_all_s(); 
     $data['$total_s'] = $config['total_s'] = $this->s_model->count_all_ss(); 

     $config['base_url'] = 'http://example.com/display/s/'; 
     $config['total_rows'] = $data['all_rows_s']; 
     $config['per_page'] = 12; 
     $config['num_links'] = 5; 
     $config['full_tag_open'] = '<div class="page_row">'; 
     $config['full_tag_close'] = '</div>'; 

     $data['row'] = $this->db->get('s_data',$config['per_page'], $this->uri->segment(3))->result(); 

     $this->pagination->initialize($config); 


     $this->template->set_theme(Settings_model::$db_config['active_theme']); 
     $this->template->set_layout('main'); 
     $this->template->title($this->lang->line('s')); 
     $this->process_partial('header', '/header'); 
     $this->process_partial('footer', '/footer'); 
     $this->process_template_build('s_view', $data); 

    } 

Но это работает потому что без таблицы из-за этой линии: $data['row'] = $this->db->get('s_data',$config['per_page'], $this->uri->segment(3))->result();

, но мне нужно сделать несколько фильтров в него, как order by id и where date > NOW(), как это возможно сделать? что бы я заменил этот get и код, который все еще работает, и снова вид WITHOUT table равен divs в пределах foreach.

Спасибо!

ответ

0

Попробуйте это:
Контроллер Функция

function func() { 
    $this->load->library('pagination'); 
    $this->load->database('default'); 
    $this->load->model('s_model'); 

    $data['all_rows_s'] = $this->s_model->count_all_s(); 
    $data['$total_s'] = $config['total_s'] = $this->s_model->count_all_ss(); 

    /*Pagination*/ 
    $config['base_url'] = 'http://example.com/display/s/'; 
    $config['total_rows'] = $data['all_rows_s']; 
    $config['per_page'] = 12; 
    $config['num_links'] = 5; 
    $config['full_tag_open'] = '<div class="page_row">'; 
    $config['full_tag_close'] = '</div>'; 
    /*Pagination*/ 

    //$data['row'] = $this->db->get('s_data',$config['per_page'], $this->uri->segment(3))->result(); 

    $data['row'] = $this->s_model->get_records($config['per_page'], $this->uri->segment(3)); 

    $this->pagination->initialize($config); 


    $this->template->set_theme(Settings_model::$db_config['active_theme']); 
    $this->template->set_layout('main'); 
    $this->template->title($this->lang->line('s')); 
    $this->process_partial('header', '/header'); 
    $this->process_partial('footer', '/footer'); 
    $this->process_template_build('s_view', $data); 

} 

Модель Функция

function get_records($limit, $offset = 0){ 
    return $this->db->where('date > NOW()')->order_by('id', 'asc')->get('s_data', $limit, $offset)->result(); 
} 
+0

пагинацию оленья кожа зависит от точки зрения. Он извлекает данные из базы данных в соответствии с вашими запросами. Это до вас, как вы собираетесь показывать эту информацию на своем сайте. Это может быть «таблица», или она может быть «divs», не имеет значения! : D –

+0

Спасибо, Саша, это сработало! – Liza

Смежные вопросы