The searching page has two or more fields like keyword
and source
:
<form class="navbar-form pull-left" action="/articles/search" method="get">
<input type="text" name="source" >
<input type="text" name="keyword" >
<button type="submit"><i class="fa fa-search"></i></button>
</form>
If we input google for source
, and input usaco for keyword
, and then submit it , the paginator of the result page will be more like this:
<ul class="pagination">
<li class="active">
<a href="/articles/search?page=1&source=google&keyword=usaco">1</a>
</li>
<li><a href="/articles/search?page=2&source=google&keyword=usaco">2</a></li>
<li><a href="/articles/search?page=3&source=google&keyword=usaco">3</a></li>
</ul>
In the controller, I cant get the pagination by $this->view->page = $paginator->getPaginate();
But how to code in the volt in order to generate the pagination HTML code above? more detailedly,
Question 1. (See the comment line in the sample code below) How to generate the URL params like &source=google&keyword=usaco
?
Question 2. $this->url->get(\''articles/search?page=\")
will cause XSS attack, how to avoid it?
{% if page.items is defined %}
<ul class="pagination">
<?php for ($i=1; $i<=$page->total_pages; $i++) {
echo "<li";
if ($i == $page->current) echo " class='active'";
echo "><a href='" . $this->url->get('articles/search?page=') . $i;
// Here, How to generate the URL params like `&source=google&keyword=usaco`?
echo "'>" . $i . "</a></li>";
}?>
</ul>
{% endif %}