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'm building a personal bibliography on my site and like most academics, I have my default display by type. However, within each type, the publications are sorted by title rather than by year. In fact, I cannot really think of a scenario where the title would be the preferable secondary sort rather than author or year.
Would it be possible to have that as an option in the settings? I would even be willing to go to the inadvisable inconvenience of hacking the biblio.pages.inc but couldn't figure out how to do it with my meager PHP/SQL skills.
Comment | File | Size | Author |
---|---|---|---|
#23 | 358154-23-sort_bytype_then_byyear.patch | 810 bytes | rbrandon |
#22 | biblio-not-sortable.png | 9.88 KB | wuwei23 |
#10 | secondary_sort_by_type_id.patch | 1.28 KB | sebos69 |
Comments
Comment #1
rjerome CreditAttribution: rjerome commentedThis is a long standing feature request which (with a bit of luck) I will try to get into the 1.0 release.
Ron.
Comment #2
sebos69 CreditAttribution: sebos69 commentedI second this request, this feature is one of the last missing for our academic needs, too!
Comment #3
rjerome CreditAttribution: rjerome commentedDone.
It's hard coded right now, but I'll work on making user configurable.
Ron.
Comment #4
techczech CreditAttribution: techczech commentedThanks Ron, I really do believe this is a default that will make sense for most people. Is it in dev now? I can't wait to test it on my site.
Dominik
Comment #5
rjerome CreditAttribution: rjerome commentedIt hasn't been checked in yet (the site was down most of the day yesterday) look for it later today.
Comment #6
rjerome CreditAttribution: rjerome commentedOk, it's been committed to the -dev version.
Ron.
Comment #7
sebos69 CreditAttribution: sebos69 commentedOK, I checked the -dev version, and it seems there is a side-effect (or an other bug?)
In previous version, selecting sorting by publication type would make the types appear in this order : book, book chapter, journal article, conference paper...
but now, the order is more like : book, conference paper, journal article.
It seems the type are now order by alphabetical order, but the previous sorting was by publication type id and was better (for me and most academics, I believe...)
Comment #8
rjerome CreditAttribution: rjerome commentedIndeed, they are sorted alphabetically (which, although might not fit your desires, is probably more understandable)
I could put an option to sort by type ID or Name.
Comment #9
sebos69 CreditAttribution: sebos69 commentedThat would be great!
Comment #10
sebos69 CreditAttribution: sebos69 commentedOk, here is a patch (against head) that does it!
Comment #11
techczech CreditAttribution: techczech commentedThanks for this Ron. I installed it on my system and it works just as advertised.
Re option to sort by ID or name, wouldn't it be better to make it possible to assign weights to the reference types? I solved the sorting problem by going into the database and changing the names of the types but I'm afraid that might have a knock on effect later on. And I assume the IDs need to stay constant. But it might be too much work to solve a relatively marginal problem.
Comment #12
rjerome CreditAttribution: rjerome commentedThat's a good idea, and they actually already have "weight" values, you just can't see them or change them :-(
If I add "table drag" to "admin/settings/biblio/fields/type" then you could just rearrange them to your hearts content.
Ron.
Comment #13
Frank Steiner CreditAttribution: Frank Steiner commentedWill this also work as "sort by year, within year by (weighted) type"? Because our main sort is by year on the global publication list, but within the years we would like to chose a sort-by-type order.
What I wonder is if we can also get this for inline calls. When I call
biblio_db_search
with two order options, only the last one is taken. Using sth. likebiblio_db_search('order', 'year,type')
doesn't work. If biblio could evaluate more complex order elements it would be possible to do sth. likebiblio_db_search('order', 'year,field(biblio_type,102,100,205)')
reaching what you plan with the drag&drop.Do you think this is possible or would parsing be too complicated? Maybe some syntatic sugar like
('order', 'year', 'and_order', 'field...')
?Note: I'm currently using the following patch for my site:
This allows any module implementing
<module>_biblio_build_query_alter(...)
to change the query to do thinks like that. Adding the field sort option etc. is simple, so I can provide the field option to my users. This might help people who need sth. like this in case you don't see chances to implement this in biblio itself.Comment #14
rjerome CreditAttribution: rjerome commentedHi Frank,
Some good ideas here, and I think it may be time to completely re-think/write the query building.
Also, FYI, it has come to my attention recently that some of these "sub-sorts" are absolutely killing large (40K+) databases. Especially if there are opposing sort orders (one is DESC and one is ASC) also the title sorts are a killer. The bottom line is that some may want sub-sorting to be optional. (See #306014: biblio causing massive use of resources)
Comment #15
Frank Steiner CreditAttribution: Frank Steiner commentedI see... Maybe an additional "sort" tab like the "filter" tab that allows to add sort criterias one after another? While still having the basic sort options on the main page... Because it seems like adding sort options is very much like adding filters. One would just need the possibility to save the chosen sort criterias as default one.
Comment #16
techczech CreditAttribution: techczech commentedI noticed that the secondary sort disappeared in 6.x-1.5. Is it still in dev? Or am I missing something?
Comment #17
rjerome CreditAttribution: rjerome commentedActually, I don't think it ever made it into the code, (at least not that I remember).
You might want to start looking into the use of Views. Biblio now has reasonably complete Views support and this allows some fairly complex sorting and filtering to be done.
Ron.
Comment #18
techczech CreditAttribution: techczech commentedIt was in the DEV version I was using until I upgraded to 1.5. But I'll look into Views. That was the flexibility, I was looking for anyway. Thanks.
Comment #19
JeniferTucker CreditAttribution: JeniferTucker commentedYep, I agree on this too. I currently have the default display by year, but it would be nice to to have the option to then sort them under each year by the first named author alphabetically.
For displaying on user profile pages, I agree too that most default displays are likely to be by type and strongly support the idea of being able to then have an option to set the sort order to be by title rather than by year.
Comment #20
techczech CreditAttribution: techczech commentedI was able to recreate this functionality with views and then some. The only bit that is missing is the export function. I submitted it as a new feature request here: #484872: export links in views
I think all the development efforts should now go towards tighter Views/CCK integration - which is where Ron seems to be headed.
Comment #21
Aren Cambre CreditAttribution: Aren Cambre commentedThis is standard functionality already available to fields (CCK) through other modules, so marking as duplicate of #682044: Support fields (CCK) in D7 Bibliography Module since that would also satisfy this.
Comment #22
wuwei23 CreditAttribution: wuwei23 commentedI've created a custom search using Views 6.x-2.8, with the 'Table' style to allow for sorting by column headers.
However, none of the Biblio fields have a sortable option in the Table configuration. I've attached a screenshot snippet to demonstrate.
Am I following the wrong approach here? Any help would be greatly appreciated.
Comment #23
rbrandon CreditAttribution: rbrandon commentedEven though this can be achieved through the use of cck and views, I still think that the original spirit of the ticket remains. The default sort should not be by type then title, but instead by type then year.
-Richard