Symfony 中的 Zend Paginator(用于 Lucene 搜索结果)
我已经在 symfony 论坛上写了这个问题,但没有结果。当然,我知道人们可能很忙或没空,所以我无法立即得到答案。但我真的需要这么快,所以我也在这里发帖。如果这是不允许的,请关闭问题。谢谢。
最初发布在这里: http://forum.symfony-project.org/viewtopic.php ?f=22&t=31537
嗨, 我有一些关于在 zend lucene 中使用 zend 分页的问题。检查旧论坛,发现这个:forum.symfony-project.org/viewtopic.php?f=21&t=27342&p=103440&hilit=zend+pagination&sid=1cdc305c262c6b3cf79fdeef25761f34#p103440 但我需要一些额外的功能。我已经尝试过上面帖子中的代码,并且它有效。但我们如何实现它呢?
检查 zend 文档,我在 /web/view/scripts/pagination.php 中创建一个视图文件 此处找到文件的代码:
framework.zend.com/manual/1.10/en/zend.paginator.usage.html
对 $this->url() 进行一些修改
变为 link_to()
然后,实际的代码如下所示:
$pager = Zend_Paginator::factory($query->execute()->getData());
$pager->setItemCountPerPage(3);
$pager->setCurrentPageNumber($request->getParameter('page', 1));
$pager->setDefaultScrollingStyle('Sliding');
Zend_View_Helper_PaginationControl::setDefaultViewPartial('_pagination.php');
$this->pager = $pager;
在视图中: <代码>
问题当然是,这样做正确吗? 那么,如何获取当前的URL并修改view中的参数呢?对于 zend,据我了解,它类似于 $this->url(array('page', 5))
。无论如何要在 symfony 中完成这个工作吗?
先谢谢了。
我也检查过并得到这个: stackoverflow.com/questions/2002648/is-there-a-symfony-helper-for-getting-the-current-action-url-and-changing-one-or
但我无法访问上面提到的pagination.php中的$sf_request。我认为这是因为 pagination.php 访问 Zend 的前端控制器。最奇怪的是,我可以访问像 UrlHelper 这样的默认助手(尝试过 url_for 和 link_to - 它有效)。
诗。抱歉,链接以粗体显示 - 现在无法发布超过 1 个链接。
I've written the question in symfony forum, but got no result. Of course I know that people may be busy or unavailable so I can't have my answer right away. But I really needs this fast, so I posted here too. If this is not permitted somehow, please just close the question. Thanks.
Originally posted here:
http://forum.symfony-project.org/viewtopic.php?f=22&t=31537
Hi,
I have some question regarding using zend pagination in zend lucene. Checked the old forum, and found this: forum.symfony-project.org/viewtopic.php?f=21&t=27342&p=103440&hilit=zend+pagination&sid=1cdc305c262c6b3cf79fdeef25761f34#p103440
But I need some additional feature for that. I've tried the code in the post above, and it works. But how do we implement it in view?
Checking zend documentation, i create a view file in /web/view/scripts/pagination.php
with the code for the file found here:
framework.zend.com/manual/1.10/en/zend.paginator.usage.html
With some modification for $this->url()
to become link_to()
Then, the code in action looks like this:
$pager = Zend_Paginator::factory($query->execute()->getData());
$pager->setItemCountPerPage(3);
$pager->setCurrentPageNumber($request->getParameter('page', 1));
$pager->setDefaultScrollingStyle('Sliding');
Zend_View_Helper_PaginationControl::setDefaultViewPartial('_pagination.php');
$this->pager = $pager;
And in view:<?php echo $pager ?>
The problem is, of course, is this the right thing to do?
Then, how can I get the current URL and modify its parameter in view? For zend, as I understands it, it's something like $this->url(array('page', 5))
. Anyway to get this done in symfony?
Thanks before.
I've also check SO and get this:
stackoverflow.com/questions/2002648/is-there-a-symfony-helper-for-getting-the-current-action-url-and-changing-one-or
But I can't access $sf_request in the pagination.php mentioned above. I think it's because the pagination.php access Zend's front controller. And the strangest thing is, I can acess the default helper like UrlHelper (tried url_for and link_to - it works).
Ps. Sorry for the links in bold - can't post more than 1 link now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
视图脚本通常具有
.phtml
扩展名,而不是.php
,这并不重要,但只是让您知道。尝试更改
为
View scripts usually have a
.phtml
extension, not.php
, that won't matter, but just so you know.Try changing
To