Table column sorting indicators are printed in IMG
tags right in the markup: <img typeof="foaf:Image" src="/misc/arrow-desc.png" alt="sort descending" title="sort descending" width="13" height="13" />
. The display of them, therefore, is not easily overrideable if you want, for example, to use a custom image or do something other than an image, like change the TH
's background color. I think they would be better implemented with a class applied to the TH
(e.g. class="sort-desc"
and class="sort-asc"
) so that the whole cell can be styled and the image can be overridden or removed. ...unless, of course, there's a reason for doing it the current way that I'm unaware of.
Comments
Comment #1
JacineI agree this should be done with CSS, but it's too late for D7, so we'll have to tackle this one in D8.
However, it's not true that you can't easily override these. There is a theme function for them:
:D
Comment #2
TravisCarden CreditAttribution: TravisCarden commented@Jacine: I couldn't find that function for the life of me! Thanks!
Comment #3
JacineYou're welcome :)
Comment #4
Sinan Erdem CreditAttribution: Sinan Erdem commentedhttp://api.drupal.org/api/drupal/includes--theme.inc/function/theme_tabl...
Comment #5
Sinan Erdem CreditAttribution: Sinan Erdem commentedAny possible way to indicate if a table header is sortable? I want to add, for example, a double arrow to the sortable headers. I tried adding the image as a background by CSS to the link. But this time the AJAX throbber icon becomes hidden.
Comment #6
TelFiRE CreditAttribution: TelFiRE commentedI'm absolutely baffled that there are no classes given. Even if you're going to use poor practice and spew out a hard-coded image that I can't change, at least give me classes so I can display none it.
As it is, if I understand correctly, if you want a fully functional and themable sortable table you have to do it a non-drupal way.
I don't know why you would insist on waiting till 8 to fix this. It's a major, major shortcoming.
Comment #7
frob@TelFiRE, why not just use an attribute selector? img[src$=arrow-asc.png]
Comment #8
TravisCarden CreditAttribution: TravisCarden as a volunteer commentedSee #2405057: Replace arrow-asc and arrow-desc images with Libricons and implement using CSS and Table sort indicators are now rendered with CSS via twig.