我正在使用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>
这是控制器:
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
));
}
没有解决方案?
答案 0 :(得分:0)
对于我现在在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>