Closed (outdated)
Project:
Views Natural Sort
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Reporter:
Created:
2 Feb 2014 at 19:13 UTC
Updated:
31 Jul 2025 at 01:11 UTC
Jump to comment: Most recent
Comments
Comment #1
esolano commentedHi Poieo,
I was able to add the Natural Sort to Table Headers. This how I did it:
That did the trick for me. I hope this helps.
Regards,
Comment #2
socialform commentedThanks ensolan, that worked great. For others, be aware that it doesnt work in the 2.0 versions because Node:Title - Natural has gone away. I had to go back to 7.x-1.4 to find this option. It would be great if the latest versions could accommodate this feature.
Comment #3
generalredneckintriguing notion. Don't know why I thought that this would have already been taken care of with the normal sort handler. Let me put this on my radar as high priority. It does make sense... and I assume that you should be able to select whether you want the arrows on the table header to sort Naturally or normally in the interface some how.
Comment #4
generalredneckFYI Poieo did mention this in https://www.drupal.org/node/2176035#comment-8440523
My bad for being a bad maintainer.
Comment #5
glottus commentedThis is what I'm looking for as well (natural sorting of a text field that actually contains numerical data) from the clickable views table header. Unfortunately, I cannot seem to get v7.x-1.4 to work at all - installing the module provides admin menu entries to re-index and configure, but I don't see the expected checkboxes on fields or any references to natural sorting anywhere within the views interface.
Comment #6
socialform commentedGlottus, if i remember right it provides a different field... an alternative to the usual title field for instance. "Node: Title - Natural" for instance. Take a closer look.
Comment #7
sansui commentedHrm - so it appears there's no way to add natural sort index to a text field, and then allow that text field to be a clickable table header in views with 2x?
Comment #8
generalredneckyeah that is the case so far. bumping this to the dev branch. Patches are welcome if anyone wants to work through it. Thanks!
Comment #9
dunx commentedLooking for this too. Happy coding!
Comment #10
generalredneckSome notes on what I've done so far and what I still need to do.
Work has started in 7.x-2.x-table-sort. I've created a new table style plugin that extends views_plugin_style_table. I've also used hook_views_plugins_alter to take over the default views table style plugin and replace it with Views Natural Sort's plugin. I don't know if this pattern will work in D8, but should be fine for D7... and we will cross that bridge later. With that said, I had to overload the Settings Form theme function and replace it with theme_views_natural_sort_style_plugin_table since they use a themeing function that has little to offer in the way of preprocessing... I've added the column "Sort Naturally" so that you will be able to choose if the field is to be sorted naturally asc/desc when clicked... since there are only 2 states.
Work that still needs to be done...
Add functionatlity that will check to see if a field can be natural sorted... and if It can, show a checkbox, kinda like the "Sortable" column in settings.
Add functionality that will actually do the sort based off the totally different "order" and "sort" query parameters provided by the table style plugin.
Comment #11
moonstorm commentedHi,
I made a quick fix which should cover all table clickables with a simple patch. This is in no way robust and I don't think it's clean enough to be committed as a patch BUT can bring resolve to people struggling with the issue right now.
Comment #12
pawel_r commented#11 worked for me. Have on mind that #11 is designed for nodes, if you want to use it with any other entity type than alternations must be done.
There is also one thing missing: join should be done by field name
Comment #13
lunk rat commentedThanks to @moonstorm for the start in #11. Anyone here willing to roll a patch and close this issue? Table header click-sorting has become an expected UI pattern for many Drupal web apps, and a lot of D7 tables could likely benefit from natural sort clickable headers.
Comment #18
mustanggb commentedCreated a merge request for the
7.x-2.x-table-sortbranch that adds the checkboxes to the views table format settings and does the actual natural sort for the case of node base fields, which is basically limits it to the node title.https://git.drupalcode.org/project/views_natural_sort/-/merge_requests/6
Next things to do would be add the ability to natural sort field api fields, then add support for other field handlers like taxonomy and such if that's wanted.
Marking as
Needs reviewfor generalredneck's attention to hopefully get this committed to the test/wip branch.Comment #19
mustanggb commented@generalredneck Any chance of getting my merge request in to move this forward?
Comment #20
generalredneckYeah.
Sorry about being silent. I've not done a lot D7 wise for a while... but since views stuff usually translates D7 to D8,9,10 pretty well... this should be a good start. I think we do need to think of a way to extend this without instantiating hard classes for each entity plugin type... but that is totally a refactor situation. This works for a first draft.
If we can get some more eyes on it, that would be awesome.
Comment #22
generalredneckFor Drupal 7. I'm going to merge it AS IS for just nodes into the main branch and release it as 2.8. I did some testing and it looks good. Big shout out to you MustangGB. I'm renaming this issue and creating a follow up for the 8.x branch. yet going to move this one back to "needs work" to address the following
Comment #23
generalredneck