Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I just tried the D8 version of the module at http://simplytest.me/project/views_natural_sort and it does not seem to work...
<strong>SORT
</strong>Content: Title
Order
Sort ascending
Sort descending
* Sort ascending naturally
Sort descending naturally
RESULT:
É title
d title
zzz title
Ðeres title
a title
å title
EXPECTED:
a title
d title
Ðeres title
É title
zzz title
å title
A README.txt with instructions for setting up the module would be nice, since I am not sure if I am missing something ...
I managed to fix the major part of the issue by changing the collation of the database table with ALTER TABLE node_field_data CONVERT TO CHARACTER SET utf8 COLLATE utf8_danish_ci;
, so that "a" is now the first letter and "å" the last in the list.
Comments
Comment #2
generalredneckMoving this to views natural sort. The author added this to the wrong issue queue.
The Drupal 8 Contrib Porting Tracker issue queue is meant for tracking the porting of modules to drupal 8.
Comment #3
malcomio CreditAttribution: malcomio at Capgemini commentedI'm seeing a similar problem. For example, I have a list of about 500 nodes - here are the first ones, using standard views sorting:
With natural sort, the order seems slightly random:
Comment #4
malcomio CreditAttribution: malcomio at Capgemini commentedDigging into the code, it looks like the views_natural_sort table is only populated by calls to views_natural_sort_store_multiple(), and this is called from implementations of hook_entity_insert and hook_entity_update.
When I tested at first, the nodes already existed when the module was enabled.
After updating the nodes, the views_natural_sort table gets populated, and sorting seems to work as expected.
Perhaps it is necessary to do something in the install hook to cover the scenario where nodes exist before the module is enabled?
Comment #5
generalredneckOk... yeah so in my first pass in translati n g the functionality over I didn't make the batch process (or any of the admin features) that were in d7. With that said this is alpha so I expected it to be pretty barebones. Here is the line in d7. We need to replicate that functionality. Several people have had reservations about batch processes on install... but I still think that's the best way to handle this since the module doesn't work without the transformed string...
http://cgit.drupalcode.org/views_natural_sort/tree/views_natural_sort.in...
Comment #6
generalredneckOk So I accidentally left the admin include from the d7 version in the repo as well. You took care of the .info file in your other ticket. AFAIK that code doesn't translate directly and would require me to create a controller and what not which I haven't done yet. The first steps though would be to create a batch process that would work based off that code. You can see the d7 code checked into the d8 branch here: http://cgit.drupalcode.org/views_natural_sort/tree/views_natural_sort.ad...
Sorry about the mess. I was seriously trying to get something "usable" up as quickly as I could in the time I had available since so many people were waiting on it. If you would take a stab at it I would appreciate it... otherwise I'll see what I can get up between now and the Christmas break.
Comment #7
ressa CreditAttribution: ressa as a volunteer commentedI see there has been a few commits for Drupal 8, are they ready to be rolled into a fresh dev-release, for testing?
Comment #8
generalredneckNegative. The branch there are commits to is a non-working WIP branch so that 1) it shows I'm working on it. 2) I can share the love with more than one person/machine via git since the changes are so vast. I'll for sure have a release this month as I've finally tangled some willing help and sponsorship.
Comment #9
ressa CreditAttribution: ressa at Ardea commentedSounds great, I am ready to test the new release when it arrives. Thanks for working on it.
Comment #10
generalredneckOk, I've got a new dev release. Give it a shot... For now you will have to manually run the batch process if you have existing content as I haven't been able to get that to work on install. Simply log in to your site and navigate to admin/structure/views/settings/views_natural_sort and hit "save" or the In Case of Emergency -> Reindex. Both will reindex the site... just the ICE Reindex button bypasses any changes you might have put in the settings form...
This still only works on Node Titles, but should work for views with a sort handler on it... (exposed or not exposed).
Comment #11
generalredneckComment #12
generalredneckOk had to make a quick fix to the batch operation as it was running the full queue on the first operation always. This fix should make it respect the batch limit that is set in configuration.
Comment #13
ressa CreditAttribution: ressa at Ardea commentedWith the latest dev-version from March 13th, the result of
Sort ascending naturally
onTitle
after running "Rebuild index":RESULT
EXPECTED
Comment #14
generalredneckSo here's the thing... What's going to happen is it's going to collate the letters based on common typically. What I would have actually expected would have been something alone the lines of
a title
å title
d title
Ðeres title
É title
zzz title
With that said, I'm kinda at the mercy of what the database collation sets the weight of characters currently.
What you can do is send me what the conversion came out to in the views_natural_sort table. Additionally, a recounting of the steps you took to test this would be helpful. I would like to know for example if you enabled VNS and then created the content or did you create the content, enable the module, and then hit the Reindex button?
If you enabled the module after the content was created and then did not hit the reindex button... then that's a possible issue as explained in above comments.
Comment #15
ressa CreditAttribution: ressa at Ardea commentedHere are the steps I went through:
6 nodes updated
)6 nodes updated
)Sort ascending naturally
) in my View was not as expected ...Comment #16
generalredneck@ressa,
Views Natural Sort is sorting as expected given Drupal's standard Collations.
I however have fixed the issue in #3. Beyond that, the D8 and D7 both sort exactly the same using the Default Collation that Drupal installs with. I also don't have a plan to support Locale any time soon as that is a major undertaking which is partly what this ticket is suggesting with changing collation to "Danish". I'm assuming these are Danish letters therefore the expectation of the sorting. Please change your collation at your own risk as I haven't a great idea of the consequences of doing so.
You will also notice that the architecture of the module currently isn't set up to handle different translations either unless each translation is in a different node...