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
    ));
}

没有解决方案 ?

4

1 回答 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>
于 2014-12-01T14:05:56.930 回答