Welcome Guest, Not a member yet? Register   Sign In
Using Pagination but with NO table ?
#1

[eluser]chefnelone[/eluser]
Hello

I have this code to do pagination using tables.
I'd like to know how to do it using DIVs instead of TABLE

How can I grab the sent data from the view?

controller: site.php
Code:
function index()
    {
        $this->load->library('pagination');
        $this->load->library('table');
        
    
        $config['base_url'] = 'http://localhost:8888/ci/index.php/site/index';
        $config['total_rows'] = $this->db->get('data')->num_rows();
        $config['per_page'] = 10;
        $config['num_links'] = 20;
        
        $this->pagination->initialize($config);
        
        $data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3));
        
        $this->load->view('site_view', $data);
        
    }

VIEW: views/site_view.php

Code:
<div>
        &lt;?php echo $this->table->generate($records); ?&gt;
        &lt;?php echo $this->pagination->create_links(); ?&gt;
</div>
#2

[eluser]arthurhanlon[/eluser]
Hey there, look at the section here: http://ellislab.com/codeigniter/user-gui...ation.html on customizing the pagination links at the bottom.

Hope this helps,
Arthur
#3

[eluser]clip[/eluser]
You will have to rewrite your view file. Instead of:
Code:
&lt;?php echo $this->table->generate($records); ?&gt;
You will need to do something like:
Code:
&lt;?php foreach($records as $record): ?&gt;
  <div class="entry">
    <h1>&lt;?php echo $record->title; ?&gt;</h1>
    <p>&lt;?php echo $record->content; ?&gt;</p>
  </div>
&lt;?php endforeach; ?&gt;
#4

[eluser]chefnelone[/eluser]
[quote author="clip" date="1280518899"]You will have to rewrite your view file. Instead of:
Code:
&lt;?php echo $this->table->generate($records); ?&gt;
You will need to do something like:
Code:
&lt;?php foreach($records as $record): ?&gt;
  <div class="entry">
    <h1>&lt;?php echo $record->title; ?&gt;</h1>
    <p>&lt;?php echo $record->content; ?&gt;</p>
  </div>
&lt;?php endforeach; ?&gt;
[/quote]

You're right, but you need to change this line also:
Code:
$data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3));

for this one:

Code:
$data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3))->result();
#5

[eluser]chefnelone[/eluser]
Pagination:
how can I hide: first_link and last_link ??

With this I can set the text for them:
Code:
$config['first_link'] = 'Start';
$config['last_link'] = 'End';
        
$this->pagination->initialize($config);

but I need to hide them, I tried with (but nope)
Code:
$config['first_link'] = FALSE;
$config['last_link'] = FALSE;
        
//AND WITH

$config['first_link'] = '';
$config['last_link'] = '';




Theme © iAndrew 2016 - Forum software by © MyBB