将项目添加到已创建的 Zend_Paginator 中?
在我的控制器中,我创建了一个像这样的分页器实例:
// On crée un objet paginator pour afficher un tableau de résultat.
$paginator = Zend_Paginator::factory($versions->getVersions($projectId));
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
然后我在我的视图中像这样迭代:
<? foreach ($this->paginator as $item): ?>
<? ($flag == "pair") ? $flag = "impair" : $flag = "pair"; ?>
<tr class="<?= $flag; ?>">
<!-- version nom de la version -->
<td>
<a href="<?= $this->url(array('module' => "admin", 'controller' => "version", 'action' => "index", 'project' => $item['idversion'])); ?>">
<?= $item['lab_version']; ?>
</a>
</td>
<!-- version nom du project -->
<td><?= $item['name_patrimony']; ?></td>
<!-- version retrodocumente ? -->
<td class="version-retrodoc">
<a href="<?= $this->url(array("module" => "doxygen", "controller" => "doxygen", "action" => "create", "version" => $item['idversion']), null, true); ?>">
<img src="<?= $this->baseUrl() . '/img/system-run.png' ?>" alt="retrodocumenté"/>
</a>
</td>
</tr>
<? endforeach; ?>
但在我的控制器中,我会处理一些条件。我的分页器实例是项目版本的集合。因此,如果有关版本的信息已正确插入数据库,我将处理主目录是否已正确创建...所有这些都在控制器中进行检查。 我的目标是添加这些变量(大多数情况下是布尔值)并将其添加到分页器实例中,这样我就可以在视图中迭代它并添加消息错误。
PS:如果有人能告诉我如何在 Stackoverflow 中正确格式化 php 代码,那将会很有帮助:-)。
in my controller I have created a paginator instance like this:
// On crée un objet paginator pour afficher un tableau de résultat.
$paginator = Zend_Paginator::factory($versions->getVersions($projectId));
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
Then I iterate over in my view like this:
<? foreach ($this->paginator as $item): ?>
<? ($flag == "pair") ? $flag = "impair" : $flag = "pair"; ?>
<tr class="<?= $flag; ?>">
<!-- version nom de la version -->
<td>
<a href="<?= $this->url(array('module' => "admin", 'controller' => "version", 'action' => "index", 'project' => $item['idversion'])); ?>">
<?= $item['lab_version']; ?>
</a>
</td>
<!-- version nom du project -->
<td><?= $item['name_patrimony']; ?></td>
<!-- version retrodocumente ? -->
<td class="version-retrodoc">
<a href="<?= $this->url(array("module" => "doxygen", "controller" => "doxygen", "action" => "create", "version" => $item['idversion']), null, true); ?>">
<img src="<?= $this->baseUrl() . '/img/system-run.png' ?>" alt="retrodocumenté"/>
</a>
</td>
</tr>
<? endforeach; ?>
But in my controller I would handle some conditions. My paginator instance is a collection of version of project. So I would handle if the home directory has been correctly created if the information about the version is correctly inserted in the db... All that are checking in the controller.
My goal is to add these variables (most of the times boolean) and add it to paginator instance so then I would iterate over it in the view and add message error.
PS: If someone could tell me how to format correctly php code in Stackoverflow it would be helpful :-).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为应该可以为分页器中的项目添加值。但是,确切的方法将取决于您在分页器中使用的适配器。例如,我将提供一个片段,展示如何向使用数组适配器的分页器中的项目添加值。
有点晚了,但我希望这对您有所帮助,也许对其他可能有类似问题的人有所帮助。
I think it should be possible to add a value to an item in your paginator. However, the exact methodology will depend on your adapter that you use in the paginator. As as example, I'll provide a snippet that shows how to add a value to an item in a paginator that uses array adapter.
Little late, but I hope that this will helpful if not to you, maybe to some other people that may have similar problem.