2013-02-28 5 views
0

항목 배열이 있습니다. 항목은 파일 경로입니다. 페이지 매김을 설정했지만 다음을 클릭하면 변경되지 않습니다. 1 페이지 당 1 개의 pdf를 표시하고 싶습니다. 다음은Zend의 페이지 매김이 작동하지 않습니다.

class IndexController extends Zend_Controller_Action 
{ 

    public function init(){} 

    public function indexAction() 
    { 
     if($_SERVER['SERVER_NAME']=="portal-dev"){ 
      $location = "/data/scan/invoice";   
      $listOfFiles = $this->readFiles($location); 
      $paginator = Zend_Paginator::factory($listOfFiles); 
      $paginator->setItemCountPerPage(1); 
      $this->view->paginator = $paginator; 
     } 
    } 


    public function readFiles($location){ 
     $pattern="(\.pdf$)"; //valid image extensions 
     $thelist = array(); 
     if ($handle = opendir($location)) { 
      while (false !== ($file = readdir($handle))) 
      { 
       if (eregi($pattern, $file)) //if this file is a valid image 
       { 
        $thelist[] = $file; //insert files into array 
        $max = count($thelist) - 1; 
        $max1 = count($thelist); 
       } 
      } 
      closedir($handle); 
     } 
     return $thelist; 
    } 
} 

index.phtml

<div id="main"> 
    <?php if(!$this->paginator){ 
     echo "No Files to process"; 
    }else{ 
    ?> 
    <table> 
     <tr> 
      <td rowspan=2></td> 
      <td></td> 
     </tr> 
     <tr> 
      <td></td> 
     </tr> 

    </table> 
    <?php if (count($this->paginator)): ?> 
    <ul> 
     <?php foreach ($this->paginator as $item): ?> 
     <li><?php echo $item; ?> 
     </li> 
     <?php endforeach; ?> 
    </ul> 
    <?php endif; ?> 

    <?php echo $this->paginationControl($this->paginator,'Sliding','partial/my_pagination_control.phtml'); ?> 
    <?php }?> 
</div> 

매김이 부분 디렉토리

<?php if ($this->pageCount): ?> 
<div 
    class="paginationControl"> 
    <!-- Previous page link --> 
    <?php if (isset($this->previous)): ?> 
    <a href="<?php echo $this->url(array('page' => $this->previous)); ?>"> 
     Previous </a> <span class="bar"> | </span> 
    <?php else: ?> 
    <span class="disabled"> Previous</span> <span class="bar"> | </span> 
    <?php endif; ?> 

    <!-- Numbered page links --> 
    <?php foreach ($this->pagesInRange as $page): ?> 
    <?php if ($page != $this->current): ?> 
    <a href="<?php echo $this->url(array('page' => $page)); ?>"> <?php echo $page; ?> 
    </a> <span class="bar"> | </span> 
    <?php else: ?> 
    <?php echo $page; ?> 
    <span class="bar"> | </span> 
    <?php endif; ?> 
    <?php endforeach; ?> 

    <!-- Next page link --> 
    <?php if (isset($this->next)): ?> 
    <a href="<?php echo $this->url(array('page' => $this->next)); ?>"> Next 
    </a> 
    <?php else: ?> 
    <span class="disabled">Next </span> 
    <?php endif; ?> 
</div> 
<?php endif; ?> 

답변

1

$paginator->setCurrentPageNumber($this->_getParam('page')); 

indexAction에 현재 페이지 번호를 설정 한 후 시도에서 발견 내 코드입니다 이처럼

$paginator = Zend_Paginator::factory($listOfFiles); 
$paginator->setItemCountPerPage(1); 
$paginator->setCurrentPageNumber($this->_getParam('page')); 
$this->view->paginator = $paginator; 
+0

작동. 왜 URL에'index/index/page/2'가 있습니까? 두 번째 인덱스 표시 – shorif2000

+0

첫 번째 인덱스는 컨트롤러 이름이고 두 번째 인덱스는 액션 이름입니다. – Reshil

+0

일단 페이지 매김을 사용하면 href 링크를'http : // baseUrl();?>/images/logo.jpg'를 입력하십시오. 이게 정상인가? 또는 그것을하는 방법? – shorif2000