我是 ZF 的新手。我在我的第一个项目中使用了 zend 分页器。它工作正常,可以切换黑白页面并获得正确的结果,但问题是我在该视图中也有其他链接看看我的视图
<?php include "header.phtml"; ?>
<h1><?php echo $this->escape($this->title);?></h1>
<h2><?php echo $this->escape($this->description);?></h2>
<a href="register">Register</a>
<table border="1" align="center">
<tr>
<th>User Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Action</th>
</tr>
<?php
foreach($this->paginator as $record){?>
<tr>
<td><?php echo $record->user_name;?></td>
<td><?php echo $record->first_name;?></td>
<td><?php echo $record->last_name;?></td>
<td>
<a href="edit/id/<?php echo $record->id;?>">Edit</a>
|
<a href="del/id/<?php echo $record->id;?>">Delete</a>
</td>
</tr>
<?php } ?>
</table>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>
<?php include "footer.phtml"; ?>
正如我所说的分页呈现和工作正常但是当我点击这些链接
<a id="edit_link" href="edit/id/<?php echo $record->id;?>">Edit</a>
or
<a id="delete_link" href="del/id/<?php echo $record->id;?>">Delete</a>
or
<a href="register">Register</a>
它没有调用所需的操作,而是使我的网址像这样
(initial link) http://localhost/zend_login/web_root/index.php/task/list
单击上述任何链接后,它就像这样
http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/8
http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/edit/id/23
http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/edit/id/register http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/edit/id/del/id/12
请注意,当页面第一次呈现时它不会发生,但是当我点击任何分页链接时,它会首先执行所需的操作并显示视图......任何帮助这里是操作
public function listAction(){
$registry = Zend_Registry::getInstance();
$DB = $registry['DB'];
$sql = "SELECT * FROM task ORDER BY task_name ASC";
$result = $DB->fetchAll($sql);
$page=$this->_getParam('page',1);
$paginator = Zend_Paginator::factory($result);
$paginator->setItemCountPerPage(3);
$paginator->setCurrentPageNumber($page);
$this->view->assign('title','Task List');
$this->view->assign('description','Below, are the Task:');
$this->view->paginator=$paginator;
}