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

Jacine’s picture

Version: 7.x-dev » 8.x-dev

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

function theme_tablesort_indicator($variables) {
  if ($variables['style'] == "asc") {
    return theme('image', array('path' => 'misc/arrow-asc.png', 'alt' => t('sort ascending'), 'title' => t('sort ascending')));
  }
  else {
    return theme('image', array('path' => 'misc/arrow-desc.png', 'alt' => t('sort descending'), 'title' => t('sort descending')));
  }
}

:D

TravisCarden’s picture

@Jacine: I couldn't find that function for the life of me! Thanks!

Jacine’s picture

You're welcome :)

Sinan Erdem’s picture

Sinan Erdem’s picture

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

TelFiRE’s picture

I'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.

frob’s picture

Issue summary: View changes

@TelFiRE, why not just use an attribute selector? img[src$=arrow-asc.png]

TravisCarden’s picture