Welcome Guest, Not a member yet? Register   Sign In
Pagination
#1

[eluser]skeletonfriend[/eluser]
How do I use the pagination class?

I have my controller, model, and view. In the view I have the correct amount of rows shown and pagination-links are there too, but when I try to click on of the page-links, I get an 404!

What can be the problem?

Code:
// controller

$config['base_url'] = base_url() . 'blog/';
$config['total_rows'] = $this->blog_model->getTotals();
$config['per_page'] = '20';
$this->pagination->initialize($config);
        
$num = $config['per_page'];
$offset = $this->uri->segment(3);
        
$data['blog_query'] = $this->blog_model->getBlogs($num, $offset);

// model

function getBlogs($num, $offset)
{
    $this->db->select('a.id, a.name, DATE_FORMAT(a.date_created, "%Y-%m-%d") AS date_created, a.author, CASE WHEN COUNT(b.comment_id) < 1 THEN "" ELSE CONCAT(COUNT(b.comment_id), " comments") END AS comment_total');
    $this->db->from('it_news a');
    $this->db->join('it_news_comments b', 'a.id = b.news_id', 'left');
    $this->db->groupby('a.id, a.name, a.author');
    $this->db->orderby('a.date_created DESC');
    $this->db->limit($num, $offset);
    $query = $this->db->get();
        
    if ($query->num_rows() > 0) { return $query->result(); }
}

// view

&lt;?php foreach ($blog_query as $row): ?&gt;
<div class="blogg-item">
    <h2>&lt;?=anchor('blog/post/'. $row->id, $row->name);?&gt;</h2>
    <p>Publicerad &lt;?=$row->date_created;?&gt; av <span>&lt;?=$row->author;?&gt; &lt;?=$row->comment_total;?&gt;</span></p>
</div>
&lt;?php endforeach;?&gt;
<div id="pager">&lt;?=$this->pagination->create_links();?&gt;</div>


Messages In This Thread
Pagination - by El Forum - 11-19-2007, 01:37 PM
Pagination - by El Forum - 11-19-2007, 03:18 PM
Pagination - by El Forum - 11-19-2007, 03:40 PM
Pagination - by El Forum - 11-19-2007, 08:19 PM
Pagination - by El Forum - 11-20-2007, 04:09 AM
Pagination - by El Forum - 11-20-2007, 04:57 PM
Pagination - by El Forum - 11-20-2007, 05:04 PM
Pagination - by El Forum - 12-18-2007, 01:29 AM
Pagination - by El Forum - 12-19-2007, 08:02 PM
Pagination - by El Forum - 12-19-2007, 09:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB