Paginate on Array - 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: Paginate on Array (/showthread.php?tid=50135) Pages:
1
2
|
Paginate on Array - El Forum - 03-15-2012 [eluser]jay2003[/eluser] Hi, I am new to code igniter and am building a photo gallery for a client. So far it uploads multiple files using uloadify, creates a unique directory to upload the files to, creates a thumbnail and watermarks. I how have a gallery page which loads a gallery and does so by doing the following; Code: public function get_images($dir_name) This is all working fine and the gallery looks great but am now stuck at pagination. Ive seen the pagination built into code igniter used when interacting with databases but as I am just loading an array based on contents of a directory how would i go about adding pagination? Any help would be much appreciated. Thanks Jason Paginate on Array - El Forum - 03-15-2012 [eluser]InsiteFX[/eluser] Basic Image Gallery With CodeIgniter Paginate on Array - El Forum - 03-15-2012 [eluser]jay2003[/eluser] Thanks very much Paginate on Array - El Forum - 05-28-2012 [eluser]jay2003[/eluser] Hi, I created a photo gallery with pagination based on this code recommended by InsiteFX but have got a problem. It doesn't seem to tho show the files in any particular order. Is it possible to get the images to display in alphabetical order? The controller that does the work is as follows Code: $c_paginate['base_url'] = base_url(). 'gallery/index'; Any help would be much appreciated. Thanks Jason Paginate on Array - El Forum - 05-28-2012 [eluser]InsiteFX[/eluser] You would do that in your model. You would use the active record order_by with asc or desc as the second parameter. Paginate on Array - El Forum - 05-28-2012 [eluser]jay2003[/eluser] There is no model as the controller is reading the contents of the folder in the controller There is no reference to the individual images in the db ... so this is where im stuck. Ive looked around and believe i need to use ksort but cant figure out where/how Thanks Jason Paginate on Array - El Forum - 05-28-2012 [eluser]InsiteFX[/eluser] SEE: PHP.NET - Sorting Arrays Paginate on Array - El Forum - 05-28-2012 [eluser]jay2003[/eluser] I've tried Code: $this->data['images'] = ksort($this->data['images']); just before the paginate line and it just causes my page not to load ... Any ideas? Thanks Jason Paginate on Array - El Forum - 05-28-2012 [eluser]InsiteFX[/eluser] Use sort, ksort is for associated arrays which you are not using. Try this Code: $this->data['images'] = sort($this->data['images']); You may need to adjust it with sort_flags Paginate on Array - El Forum - 05-28-2012 [eluser]jay2003[/eluser] I just get a blank screen when I try that too... |