• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination Not working?

#1
[eluser]Unknown[/eluser]
Hi,
This is my code i want pagination to work but its not working, can anybody help here, if i am taking array in construct function then its working but i want it should work in index.
Thanks
public function index($album,$start=0)
{
$album=str_replace(' ',' ',$album);
$this->album=$album;
$this->data= array(
'dir' => array('original' =>'images/'.$this->uid.'/'.$this->album.'/original/' ,'thumb' => 'images/'.$this->uid.'/'.$this->album.'/thumbs/'),'total' => 0,'images' => array(),'error' => '');
$c_paginate['base_url'] = site_url('image/index').'/'.$album;
$c_paginate['per_page'] = '4';
$finish = $start + $c_paginate['per_page'];
if (is_dir($this->data['dir']['thumb']))
{
$i = 0;
if ($dh = opendir($this->data['dir']['thumb']))
{
while (($file = readdir($dh)) !== false) {
// get file extension
$ext = strrev(strstr(strrev($file), ".", TRUE));
if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif' || $ext == 'x-png') {
if ($start <= $this->data['total'] && $this->data['total'] < $finish) {
$this->data['images'][$i]['thumb'] = $file;
$this->data['images'][$i]['original'] = str_replace('thumb_', '', $file);
$i++;
}
$this->data['total']++;
}
}
closedir($dh);
}
}
$c_paginate['total_rows'] = $this->data['total'];
$this->pagination->initialize($c_paginate);
$this->data['files']=directory_map('./images/'.$this->uid);

$this->data['album'] = $album;

$this->data['data'] = $this->data;
// $this->data['data']=$this->data11;
$this->load->view('images/index', $this->data);
}

if i put this code on my construct function then it working
$this->data= array(
'dir' => array('original' =>'images/'.$this->uid.'/'.$this->album.'/original/' ,'thumb' => 'images/'.$this->uid.'/'.$this->album.'/thumbs/'),'total' => 0,'images' => array(),'error' => '');

but i want this on my index function.
can you help me in this regard.
Thanks


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.