I'd like to use KnpPaginatorBundle for paging in symfony2.
I don't know how to describe the search criteria if you want to include them in paging in the list of search results.
/blog/February 2016
with the action accessed at the URL:
if 2016 is acquired under the name year and 02 is acquired under the name month.
I would like to add the query year=2016&month=02 to the second page.
How do I describe it?
$paginator=$this->get('knp_paginator');
$posts=$paginator->paginate($query,$page,3);
I think I will add it here somehow.
I couldn't find a way to write it.
Thank you for your cooperation.
symfony2
I'll write it down because I solved it myself.
Apparently, Knp_paginator does not have the ability to pass parameters to itself.
Implement the following actions:
$param=array('year'=>$year,'month'=>$month);
$paginator = $this->get('knp_paginator');
$pagination=$paginator->paginate($query,$page,3);
return$this->render('Notice/index.html.twig', array('pagination'=>$pagination,'param'=>$param));
The template contains
{%if pagination.totalItemCount>0%}
{% include "Common/pager.twig" with {'pages':pagination.paginationData, 'param':param, 'route'=>'notice_index'}%}
{% endif%}
The contents of pager.twig are
{%if pages.previous is defined%}
<li><a href="{ path(routes, param | merge({'page':pages.previous}))}}"aria-label="Previous"><spanaria-hidden="true">forward</span>>>
{% endif%}
{% for page in pages.pagesInRange%}
<li {%if page==pages.current%} class="active"{%endif%}><a href="{{path(routes,param|merge({'page':page}))}">>span>{{page}}}<</span>>>>>>
{% endfor%}
{% if pages.next is defined%}
<li><a href="{{path(routes, param|merge({'page':pages.next}))}}"aria-label="Next"><spanaria-hidden="true">Next;/span>>>a>>>
{% endif%}
This is how it worked.
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
581 PHP ssh2_scp_send fails to send files as intended
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.