Pagination Not working? - 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 Not working? (/showthread.php?tid=60917) |
Pagination Not working? - El Forum - 07-30-2014 [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 |