• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to make pagination from read folder?

#1
[eluser]codingmumet[/eluser]
how to make pagination data from read folder?

Quote: function dir_list($dir)
{
if ($dir[strlen($dir)-1] != '/') $dir .= '/';

if (!is_dir($dir)) return array();

$dir_handle = opendir($dir);
$dir_objects = array();
while ($object = readdir($dir_handle))
if (!in_array($object, array('.','..')))
{
$filename = $dir . $object;
$file_object = array(
'name' => $object,
'size' => filesize($filename),
// 'perm' => permission($filename),
// 'type' => filetype($filename),
'time' => date("d F Y H:iConfused", filemtime($filename))
);
$dir_objects[] = $file_object;

}
return $dir_objects;
}


tq

#2
[eluser]Madmartigan1[/eluser]
Without getting into how to actually code it, you could use GET parameters or URI segments as your "offset", and then read the array keys of $dir_objects to display the items.

So if we are on files/page/20, you can do something like this:
Code:
$per_page = 10;

$offset = $this->uri->uri_segment(3);

$dir_objects = array_slice($dir_objects, $offset, $per_page);

I would just use standard techniques to create the pagination links, I'm pretty sure the CI pagination class won't help.

Edit: Above code won't work exactly, but should get you on the right track I hope!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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