我正在使用 KnpPaginatorBundle,我想知道是否可以像这样获得没有别名的网址( t .country)
/travels?sort=country&direction=asc
不是这样
/travels?sort=t.country&direction=asc
这是形式:
<select class="select_styled white_select" id="sort_list" name="option">
<option value="">-------</option>
{{ knp_pagination_sortable(pagination, 'Country A-Z', 't.country', {'sort': 'country', 'direction': 'asc'}) }}
{{ knp_pagination_sortable(pagination, 'Country Z-A', 't.country', {'sort': 'country', 'direction': 'desc'}) }}
</select>
这是 Controller :
public function listAction($page, Request $request)
{
$em = $this->getDoctrine()->getManager();
$paginator = $this->get('knp_paginator');
$qb = $em->getRepository('ProjectTravelBundle:Travel')->getListTravelsFrontend();
$pagination = $paginator->paginate(
$qb,
$request->query->get('page', $page)/*page number*/,
10/*limit per page*/
);
return $this->render('ProjectFrontendBundle:Frontend:list.html.twig',array(
'pagination' => $pagination
));
}
没有解决方案 ?
最佳答案
对于我现在在 KnpPaginatorBundle 阅读的内容,您似乎需要以下代码:
<select class="select_styled white_select" id="sort_list" name="option">
<option value="">-------</option>
{{ knp_pagination_sortable(pagination, 'Country A-Z', 't.country', {'direction': 'asc'}) }}
{{ knp_pagination_sortable(pagination, 'Country Z-A', 't.country', {'direction': 'desc'}) }}
</select>