[ASK] Pagination Data in Array with Zend Framework ?
Posted: Sun Feb 28, 2010 11:52 am
hii all..
I want to ask.. how to pagination data in array with zend framework ?
If pagination data from tabel in database, that's work fine, but if I create my own data in array, it's not working..
this is my example code:
> in model:
> in controller:
> in view:
can anybody help me ? thanks before.. 
I want to ask.. how to pagination data in array with zend framework ?
If pagination data from tabel in database, that's work fine, but if I create my own data in array, it's not working..
this is my example code:
> in model:
Code: Select all
public function getFolder() {
if(!($open = opendir($this->folder))) {
die("Cannot open directory..!!");
}
$result = array();
$n = 0;
while($folder = readdir($open)) {
if(is_dir($this->folder . $folder) == true) {
if($folder <> "." and $folder <> "..") {
$result[$n]['foldername'] = $folder;
$n += 1;
}
}
}
closedir($open);
return $result;
}Code: Select all
public function galleryAction() {
$currentPage = $this->_request->getParam('page', 1);
$folder = "pictures/gallery/";
$PicturesManager = new Default_Model_PicturesManager();
$PicturesManager->folder = $folder;
$folders = $PicturesManager->getFolder();
//Initialize the Zend_Paginator
$paginator = Zend_Paginator::factory($folders);
//Set the properties for the pagination
$paginator->setItemCountPerPage(20);
$paginator->setPageRange(10);
$paginator->setCurrentPageNumber($currentPage);
$this->view->folders = $paginator;
}Code: Select all
if(is_array($this->folders)) {
foreach($this->folders as $folder) {
echo $folder[''foldername] ."<br>";
}
} else {
echo "empty";
}