CodeIgniter Forums
Pagination Class Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Pagination Class Problem (/showthread.php?tid=55081)



Pagination Class Problem - El Forum - 10-09-2012

[eluser]MrMahi[/eluser]
Hey Folks,

I have a problme with the very simple looking pagination class.

That's the way I put it in my Controller:

Code:
public function index()

{

  
  $data['news'] = $this->news_model->get_news();
  $data['title'] = 'News archive';
  $this->load->view('templates/header', $data);
  
  $this->load->library('pagination');
  $config['base_url'] = 'http://localhost/codeigniter/index.php/news/';
  $config['total_rows'] = 50;
  $config['per_page'] = 3;
  $this->pagination->initialize($config);
  
  $this->load->view('news/index', $data);
  $this->load->view('templates/footer');
}

and that's how I put in in the view:

Code:
<?php foreach ($news as $news_item): ?>

<div class="newscontainer">
    <h2>&lt;?php echo $news_item['title'] ?&gt;</h2>
    <div class="newstext">
        &lt;?php echo $news_item['text'] ?&gt;
    </div>
    <p class="news"><a href="news/&lt;?php echo $news_item['slug'] ?&gt;">mehr</a></p>
</div>
&lt;?php endforeach ?&gt;

<div id="pagination">&lt;?php echo $this->pagination->create_links(); ?&gt;</div>

But this is not working. Pagination is in the Site but the results are not reduced and the links from the pagination don't work either.

The problem is that the results from the news query are not connected to the pagination.

What do I have to change?

Kind regards,
Jens