It looks like you're new here. If you want to get involved, click one of these buttons!
$list_where = array('featured' => 'yes'); $model = 'projects_model'; $projects = fuel_model($model, array('find' => 'all','limit' => 10 ,'where' => $list_where)); ?> <?php if (!empty($projects)) : ?> <?php foreach($projects as $project) : ?> <h5><?php echo $project->heading; ?></h5> <p> <?php echo $project->description; ?> </p> <?php endforeach; ?> <?php endif; ?>
$CI =& get_instance(); $CI->load->library('pagination'); $CI->load->model('projects_model'); $limit = 10; $offset = $CI->input->get('offset'); $total = $CI->projects_model->record_count(); $projects = $CI->projects_model->find_all($list_where, '', $limit, $offset); $config['base_url'] = 'projects'; $config['total_rows'] = $total; $config['uri_segment'] = 2; $config['per_page'] =$limit; $config['query_string_segment'] = 'offset'; $config['page_query_string'] = TRUE; $config['num_links'] = 5; $CI->pagination->initialize($config); $links = $this->pagination->create_links(); echo $links;
$links = $this->pagination->create_links(); to $links = $CI->pagination->create_links();
Comments
http://ellislab.com/codeigniter/user-guide/libraries/pagination.html
The fuel/modules/fuel/controllers/module::list_items method uses it and passes a $pagination variable to the view.
for example, I have this view
$list_where = array('featured' => 'yes'); $model = 'projects_model'; $projects = fuel_model($model, array('find' => 'all','limit' => 10 ,'where' => $list_where)); ?> <?php if (!empty($projects)) : ?> <?php foreach($projects as $project) : ?> <h5><?php echo $project->heading; ?></h5> <p> <?php echo $project->description; ?> </p> <?php endforeach; ?> <?php endif; ?>
$CI =& get_instance(); $CI->load->library('pagination'); $CI->load->model('projects_model'); $limit = 10; $offset = $CI->input->get('offset'); $total = $CI->projects_model->record_count(); $projects = $CI->projects_model->find_all($list_where, '', $limit, $offset); $config['base_url'] = 'projects'; $config['total_rows'] = $total; $config['uri_segment'] = 2; $config['per_page'] =$limit; $config['query_string_segment'] = 'offset'; $config['page_query_string'] = TRUE; $config['num_links'] = 5; $CI->pagination->initialize($config); $links = $this->pagination->create_links(); echo $links;
I was getting this error,
Message: Undefined property: MY_Loader::$pagination
so updated this part
$links = $this->pagination->create_links(); to $links = $CI->pagination->create_links();
and it worked. thanks.