I’m using the CakePHP pagination helper in my view to display the sorting links like this:
<div class="top-bar">
<div class="sorts">
<?php
echo $this->Paginator->sort('uploaded');
?>
•
<?php
echo $this->Paginator->sort('views');
?>
•
<?php
echo $this->Paginator->sort('orig_name', 'Name');
?>
</div>
<div class="clear"></div>
</div>
It works fine, but I wanted to display them a little differently. I want the sorting direction (asc or desc) to be displayed in the sorting link.
For example, if I’m sorting by time uploaded ASC, I want the linkt to display Uploaded desc, and if I click that and sort uploads by DESC, I want it to then display Uploaded asc. Basically the opposite of what it’s currently sorted by.
Is this possible? I’ve looked at the documentation on the pagination helper and it doesn’t look like it is.
You could use CSS to do this like the default cake.generic.css does it:
What the core css looks like is:
The links get a class added to them with the direction they are currently being sorted with, so you can use that to add other styles if you need to.