Symfony2,不要在KnpPaginatorBundle的URL中使用别名

4
我正在使用KnpPaginatorBundle,想知道是否可能获得没有别名(t.country)的URL,如下所示:
/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
    ));
}

没有解决方案吗?
1个回答

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>

但这给我相同的结果,一个具有别名的URL,无法从URL中删除别名吗? - hous
@hous 这个功能在这里被请求:https://github.com/KnpLabs/KnpPaginatorBundle/issues/196 - webDEVILopers

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接