Phalcon - 如何将动态参数的Url查询字符串转换为Volt以创建分页

时间:2015-11-19 12:41:28

标签: php model-view-controller pagination phalcon

我有一个由“搜索表单”生成的查询字符串

results?pagefrom=18&pageto=30&country=2&state=&city=0&keyword=&status=all&cmd=basic_search&Submit=Start+Searching

我需要知道如何将这个进入下面的伏特中的分页生成

<li class="previous"><a href="/search/results?page={{ page.before }} & NEEDS TO ADD ABOVE QUERY AS IT IS HERE TO WORK ">Previous</a></li>

1 个答案:

答案 0 :(得分:3)

我使用的是这样的东西:

response

为了更方便,请创建marco:

<li class="previous"><a href="/search/results?<?php echo http_build_query(array_merge($this->request->getQuery(), ['page' => $page->before])); ?>">Previous</a></li>

或者您可以将此功能添加到伏特编译器:

{%- macro pagination_url(url, page) %}
    {{ url }}?<?php echo http_build_query(array_merge($this->request->getQuery(), ['page' => $page->before])); ?>
{% endmacro %}

<li class="previous"><a href="{{ pagination_url('/search/results', page.before) }}">Previous</a></li>