CodeIgniter Forums
pagination help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: pagination help (/showthread.php?tid=26657)

Pages: 1 2


pagination help - El Forum - 01-20-2010

[eluser]theprodigy[/eluser]
print_r your $data array after adding the call to create_links() to see what is being passed back to your pagination element:
Code:
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
print_r($data);  // <---- add this here
$this->load->view('stocks_view',$data);

if it's adding the correct data (looks to be 2 pages), try adding the print_r() to your $pagination variable in your view.


pagination help - El Forum - 01-20-2010

[eluser]sasori[/eluser]
@theprodigy & @Maria Claria

i did tried to analyze and print the $data
Code:
$this->load->model('stock_model');
      $per_page = 10;
      $total = $this->stock_model->count_posts();
      $data['stocks'] = $this->stock_model->getStocks($per_page,$this->uri->segment(3));
      $this->load->library('pagination');
      $config['base_url'] = 'http://myapp/welcome/stocks/';
      $config['total_rows'] = $total;
      $config['per_page'] = $per_page;
      $config['uri_segment'] = '3';
      $this->pagination->initialize($config);
      $data['pagination'] = $this->pagination->create_links();
      print_r($data);
      $this->load->view('stocks_view',$data);

view
Code:
&lt;?php echo $pagination;  ?&gt;
i was getting this
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: pagination

Filename: views/stocks_view.php

Line Number: 31

i dunno why was 'pagination' is undefined when i already included it on the controller $data array


pagination help - El Forum - 01-20-2010

[eluser]maria clara[/eluser]
that means it has a null value. the scripts are not reading it. you have to declare the $pagination.

try this in your view:
&lt;?=lang('pagination');?&gt;

hope that works.


pagination help - El Forum - 01-20-2010

[eluser]theprodigy[/eluser]
ok, try one more thing, after that, I'm completely lost.

Instead of:
Code:
$this->load->view('stocks_view',$data);
try:
Code:
$this->load->vars($data);
$this->load->view('stocks_view');



pagination help - El Forum - 01-20-2010

[eluser]sasori[/eluser]
@maria clara
i tried &lt;?=lang('pagination');?&gt;
i got a call to undefined function lang error

@theprodigy
I got the same error, it just got moved to line 33


pagination help - El Forum - 01-20-2010

[eluser]maria clara[/eluser]
view:
&lt;?php echo $pagination; ?&gt;

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

$data['pagination'] = $this->pagination->create_links();


$this->load->view('stocks_view', $data);


pagination help - El Forum - 01-20-2010

[eluser]sasori[/eluser]
[quote author="maria clara" date="1263992323"]view:
&lt;?php echo $pagination; ?&gt;

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

$data['pagination'] = $this->pagination->create_links();


$this->load->view('stocks_view', $data);[/quote]

it doesn't work, its the same code i used some hours ago

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: pagination

Filename: views/stocks_view.php

Line Number: 33

line 33 = &lt;?php echo $pagination; ?&gt;


pagination help - El Forum - 01-20-2010

[eluser]maria clara[/eluser]
look at this link http://pinoytech.org/blog/post/pagination-with-codeigniter an article about pagination in CI. i have used jquery for my pagination.


pagination help - El Forum - 01-20-2010

[eluser]sasori[/eluser]
that page got a trojan downloader according to my anti-virus.
but anyway, thank you very much to both of you
@maria clara
@theprodigy
for spending sometime helping.


pagination help - El Forum - 01-20-2010

[eluser]John Pantoja[/eluser]
Got hit with the av block as well, sucks as I'm getting around to this topic soon. Wonder if it's the common attack on Filipino sites (have to remind el wifo again not to visit her pr0n sites).