Symfony2, Do not use alias in url with KnpPaginatorBundle

683 views Asked by At

I'm using KnpPaginatorBundle and I would like to know if it is possible to get an url without alias (t.country) like this

/travels?sort=country&direction=asc 

not like this

/travels?sort=t.country&direction=asc

This the form :

<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>

and this is the 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
    ));
}

no solution ?

1

There are 1 answers

2
Manolo On

For what I've read right now at KnpPaginatorBundle, it seems that you need this code:

<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>