Zend_Paginator 与查询参数链接

发布于 2024-10-12 02:07:30 字数 261 浏览 0 评论 0原文

您能否告诉我如何与 Zend_Paginator 建立链接,如下所示: http://url/controller/action?id=47&page=2 。 我想向 url 查询添加 url 附加参数,例如 url?id=value,而不是像这样的参数: url/控制器/操作/参数/值。您还可以告诉我如何将视图变量传递给页面之外的部分吗? 谢谢。

Could you please tell me how to make link with Zend_Paginator like this:
http://url/controller/action?id=47&page=2.
I want to add to url additional paramter to the query of url like url?id=value, not paramater like this one:
url/controller/action/param/value. Could you also tell please how to pass a variable for view to partial aside from page.
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

◇流星雨 2024-10-19 02:07:30

有一个默认的视图助手 URL 是为了处理这个问题而创建的。

您可以使用以下内容生成您的网址:

echo $this->url(array('controller' => 'controllerName',
                      'action'     => 'actionName',
                      'param1'     => 'param1',
                      'param2'     => 'param2));

如果您省略一些参数,则帮助程序将重用查询网址中的那些参数

因此,使用 Zend_Paginator 您可以这样:

$pages = $this->paginator->getPages();

// previous
echo $this->url(array('page' => ($pages->current -1)));

// current
echo $this->url(array('page' => ($pages->current)));

// next
echo $this->url(array('page' => ($pages->current +1)));

** 编辑 **

反映我的第一条评论的示例

echo $this->url(array('controller' => 'controllerName', 'action' => 'actionName')) . '?user=' . $id . '&page=' . $pageNumber

There is the default view helper Url that is made for handling that.

you can generate your url with the following :

echo $this->url(array('controller' => 'controllerName',
                      'action'     => 'actionName',
                      'param1'     => 'param1',
                      'param2'     => 'param2));

If you omit some of the params, the helper will reuse those that were in the query url

So, with Zend_Paginator you go this way :

$pages = $this->paginator->getPages();

// previous
echo $this->url(array('page' => ($pages->current -1)));

// current
echo $this->url(array('page' => ($pages->current)));

// next
echo $this->url(array('page' => ($pages->current +1)));

** EDIT **

Exemple to reflect my first comment

echo $this->url(array('controller' => 'controllerName', 'action' => 'actionName')) . '?user=' . $id . '&page=' . $pageNumber
冷情 2024-10-19 02:07:30

所以,如果我正确理解这篇文章...这是您的解决方案,用于使 $_GET 或 $_POST 值在分页器的结果集中为每个后续页面加载持久存在?我有一个返回结果的搜索函数,但是当我尝试对结果进行分页时,后续页面加载会取消设置 $_POST 变量,并且我开始返回所有结果,因为通配符搜索变为 SELECT * FROM table WHERE col LIKE ' %%'。不是我想要的

编辑:我将关键字加载到 zend_cache() 中,并通过 URI 传递缓存的 id(关键字的 md5() 值)在页面加载时将它们回调出来。如果有人感兴趣我会发布代码

so if i understand this post(s) correctly ... this is your solution for making a $_GET or $_POST value persistent for each subsequent page load within a Paginator'ed set of results? i have a search function that's returning results but when i try to paginate through the results the subsequent page loads unsets that $_POST variable and i start returning all of the results because the wildcard search becomes SELECT * FROM table WHERE col LIKE '%%'. not what i want

EDIT: i am loading the keywords into zend_cache() and calling them back out on page load by passing the id of the cache ( the md5() value of the keyword ) by way of the URI. if anyone's interested i'll post the code

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文