我正在尝试使用Symfony2,KnpPaginator和Solarium进行分页。 没有返回错误,也没有显示分页。 {{pagination.getTotalItemCount}}返回“2”,而不是更多。实际上,它计算“array($ client,$ select)”中的参数个数。
有什么想法吗?
来自控制器:
$my_query = 'manufacturer:'.$pays.' AND description:*inclus* AND terms:[* TO *]';
// Create new solarium instance
$client = $this->get('solarium.client');
$select = $client->createSelect();
//$select->setRows(15);
$select->setQuery($my_query);
$select->addSort('price', $select::SORT_ASC);
if (isset($start))
{
$select->setStart($start);
}
$resultsolr = $client->select($select);
$nb_result = $resultsolr->getNumFound();
// Nav facettes
$query = $client->createSelect();
$query->createFilterQuery('inclus')->setQuery('description:*inclus* AND terms:[* TO *]');
$facetSet = $query->getFacetSet();
$facetSet->createFacetField('pays')->setField('manufacturer')->setMincount(1);
$resultset = $client->select($query);
$facet = $resultset->getFacetSet()->getFacet('pays');
//Pagination
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(array($client,$select), $this->get('request')->query->get('page', 1)/*page number*/,
20/*limit per page*/);
return $this->render('TravelTravelBundle:Default:sejours_par_pays.html.twig',
array('resultsolr' => $resultsolr,
'pays' => $pays,
'facet' => $facet,
'nb_result' => $nb_result,
'pagination' => $pagination));
}
从视图:
<div class="count">
{{ pagination.getTotalItemCount }}
</div>
编辑:我找到了答案(法语):http://inside.inclusive.fr/2013/09/knppaginatorbundle-et-solarium/