Attached is a patch for tablesort.inc much cleaner, friendlier and more consistent way to theme the tablesort icons.
Marking as a bug becuase it is inconsistent with the rest of drupal..

Please review and apply!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Stefan Nagtegaal’s picture

Setting status to 'Patch' instead of 'Fixed' so it shows up in the patch queue

Dries’s picture

Please move the proposed theme functions to includes/theme.inc (so Doxygen includes them in the list of theme_ functions).

Steven’s picture

We should avoid entities like   in the code. This can be achieved through CSS instead in the theme.

Steven’s picture

(ack submitted too early)

Also, I wonder about the granularity of these theme functions. I don't see the point in putting ascending/descending in a separate function: they are different styles for the same element (the tablesort indicator).

Dries’s picture

Stefan's patch actually removes the entities, not (or is my jet lag worse than it appears)?

Stefan Nagtegaal’s picture

Updated patch which removes the   and moves the theme_tablesort_asc() and theme_tablesort_desc() to theme.inc.

This is much better imo than the current approach..

Steven’s picture

Yeah the entity was actually a +1... I should stop doing so much things at the same time. My other concern is still valid though: theme functions should theme page /elements/, not versions of that element.
Otherwise we would have theme_node(), theme_node_sticky(), theme_node_teaser(), ...

Dries’s picture

I agree with Steven. We should have a function called theme_tablesort_header($style) where $style can be either 'ascending' or 'descending'.

Dries’s picture

Robin Monks’s picture

Assigned: Stefan Nagtegaal » Robin Monks
FileSize
1.49 KB

Here is a new patch with theme_tablesort_header($style) that takes either asc or desc as arguments.

Tested to work on Drupal CVS HEAD.

Robin

Bèr Kessels’s picture

I am not sure about teh switch; AFAIK there will be only asc and desc. So an if would be enough. Saves some lines of code, like "break"s; etc.

Robin Monks’s picture

FileSize
1.6 KB

Here is a new patch using if instead of the switch.

Robin

Robin Monks’s picture

FileSize
1.61 KB

Thox suggested using indicator instead of header.

Robin

mfb’s picture

+1 looks good.

Jose Reyero’s picture

+1
Tested the patch -applies with some line shift-, and it works

Dries’s picture

Committed to HEAD. Thanks.

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)