KnpPaginatorBundle, how to set fixed direction for sortable link

40 Views Asked by At

SLOVED:

Solved by adding an extra empty array {} as mentioned here https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/docs/templates.md#choose-the-sorting-direction

{{ knp_pagination_sortable(properties, 'Price Low To High', 'p.price', {},{'direction': 'asc'}) }}

The original question:

I have this sortable link with asc direction

 <li>{{ knp_pagination_sortable(properties, 'Price Low To High', 'p.price', {'direction': 'asc'}) }}</li>

when I click on this link, the direction becomes 'desc' in the url parameters.

How can we set a fixed direction and keep the same direction ?

In the source code of the bundle there is this code talks about a "fixed direction" but I didn't find how to set it in the configuration

   namespace Knp\Bundle\PaginatorBundle\Helper;

   final class Processor
   {
       if ($sorted) {
            if (!$hasFixedDirection) {
                $direction = 'asc' === \strtolower($direction) ? 'desc' : 'asc';
            }

            $class = 'asc' === $direction ? 'desc' : 'asc';
        } else {
            $class = 'sortable';
       }
   }
0

There are 0 best solutions below