Hi,
we use primary and secondary author fields for formatting purposes to set authors from our chair in bold. However, the order in which the authors are listed should not be influenced by this, i.e., they should stay in the order they were entered, not primary authors first, then secondary etc.

The attached patch adds an option in the "Sorting" fieldset on the preferences page to chose between "order authors by type" or "by order in which they were entered". It defaults to the current biblio behaviour, i.e., order by type, then by rank.

If you change the option, it will remove the "ORDER BY bc.ct_id ASC" from the query in biblio_load_contributors and so just order by rank.

Please let me know what you think about this feature.
cu,
Frank

CommentFileSizeAuthor
biblio_keep_author_order.patch1.73 KBFrank Steiner

Comments

rjerome’s picture

The rational for classifying the authors (as I'm sure you are aware) was that most output formats (APA,CSE, etc) format the various contributor types differently (typically each is a separate group). What I hadn't counted on was that a format (yours) might want to intersperse those different types of authors (it never fails, there's always an edge case ;-). I'd like to think on this one a bit.

Frank Steiner’s picture

Yes, I feel that our chair web pages hit many unusual cases for drupal :-) Be that the breadcrumbs for user generated menus, protecting groups of pages with passwords but without logins or the unusual mixture of single- and dual-languages and submenus .

I have another one for biblio: the author filter should only show the primary authors (those who are working at our chair). But fortunately I'm able to solve this easily with hook_form :-)

Frank Steiner’s picture

Another thought on this: What I want to do currently works fine but only because the rank in _save_contributors is calculated as

      'rank' => $rank[$author['type']]++,

But $author['type'] is not defined in the $authors array passed to _save_contributors and therefore $rank just counts up. So when you have some normal authors and some editors and the editors came last in the edit form, the table looks

+-----+------+-----+-------+------+
| nid | vid  | cid | ct_id | rank |
+-----+------+-----+-------+------+
| 614 | 1056 |  22 |     4 |    0 | 
| 614 | 1056 |  23 |     4 |    1 | 
| 614 | 1056 |  24 |    35 |    2 | 
| 614 | 1056 |   9 |     4 |    3 | 
| 614 | 1056 |  25 |    66 |    4 | 
| 614 | 1056 |  26 |    66 |    5 | 
| 614 | 1056 |  27 |    66 |    6 | 
+-----+------+-----+-------+------+

while I guess the code in _save_contributors is meant to create a table like

+-----+------+-----+-------+------+
| nid | vid  | cid | ct_id | rank |
+-----+------+-----+-------+------+
| 614 | 1056 |  22 |     4 |    0 | 
| 614 | 1056 |  23 |     4 |    1 | 
| 614 | 1056 |  24 |    35 |    0 | 
| 614 | 1056 |   9 |     4 |    2 | 
| 614 | 1056 |  25 |    66 |    0 | 
| 614 | 1056 |  26 |    66 |    1 | 
| 614 | 1056 |  27 |    66 |    2 | 
+-----+------+-----+-------+------+

If that was the case, my patch wouldn't help.

However, I wonder if there is any advantage in restarting the rank for every author type from 0. So if you think about this, please consider if we couldn't change that into just a 'rank' => $rank++ to keep a unique rank value for every author of a node. That would allow to keep the order in which authors were entered while still allowing any sort lik "first by author type, then by rank" as you need them for the other styles.

Could be sth. like

 function _save_contributors($authors, $nid, $vid, $update = FALSE) {
-  $rank = array();
+  if (variable_get('biblio_sort_contributors', 'type') == 'type') 
+    $rank = array();
+  else
+    $rank = 0;
:
:
+    $_rank = is_array($rank) ? $rank[$author['type']]++ : $rank++
     $link_array = array(
       'nid' => $nid,
       'vid' => $vid,
       'cid' => $cid,
-      'rank' => $rank[$author['type']]++,
+      'rank' => $_rank,
       'ct_id' => $author['ct_id']
     );
rjerome’s picture

Ok after staring at the biblio_contributor_type table for a while it finally dawned on me what's wrong with this picture... the ct_id field is completely redundant, which is why this is so confusing. type+tid+ctdid make a unique key and biblio_contributor.ct_id can be changed to biblio_contributor.type, then I think this will make much more sense since we won't be approaching the contributor type from two different directions.

Also I'm going to rename these fields to better reflect their purpose, even I'm having a hard time keeping track of cid, ct_id, ctdid.

Ron.

Frank Steiner’s picture

I think you are right. However, if we have an entry from biblio_contributor with type instead of ct_id, we can't determine the ctdid by just using the biblio_contributor_type table anymore. We need to query the biblio table, too, because we need tid+type to get the ctdid and biblio_contributor only contains the type if you replace the ct_id by type.

I haven't checked the biblio code to see if this situation happens at all, I think it's just sth. to keep in mind. And I guess an additional db query at some point is fine for gaining a easier and better-to-understand data structure.

rjerome’s picture

Hmm, I guess you have a point, but given that contributors are always attached to some biblio entry, I think you will always have the biblio.biblio_type value at hand but I'll check.

Frank Steiner’s picture

Status: Needs review » Fixed

Just see that this is fixed in 6.x-1.1. Thanks a lot!

Frank Steiner’s picture

Status: Fixed » Active

Oh, I was a bit too fast. The 1.0 release has changed things in a way that make it absolutely impossible to mix authors of different types. As we have records where a secondary author has a higher rank than a primary author, those records will be changed when loading and saving again. That's not good.

I will have to alter the whole contributor GUI stuff to get the old behaviour back. This is disappointing, I thought things would get better with the new author stuff. But they are less flexible now :-(

rjerome’s picture

Actually, I think you can still do the similar sort of thing, but it may require some configuration to achieve it. Correct me it I'm wrong, but I think you are saying that within the primary author string, you have an author you want to give some other classification as well (i.e. Chair)?

You can add author types on "admin/settings/biblio/author/type" and then associate types with categories here "admin/settings/biblio/fields", if you select multiple types for a given category, then a drop down list will appear in the input form next to the authors within that category and you can classify them as a given type within the category.

Ron.

Frank Steiner’s picture

This sounds like I missed some GUI functionality when trying around. Let me take another look tomorrow (I'm off work already) and I'll post back what I've found.

Thanks so far for caring!

Frank Steiner’s picture

Status: Active » Fixed

Ok, I take everything back, I claim the opposite and I apologize :-)

In fact, the new GUI hasn't restricted but extended flexibility in a way that I was just too stupid to catch it :-) Due to the way of upgrade of our existing records into the new release I didn't realize it was possible to have two types share the same contributor fieldset. Now I must way: WOW! This is really cool! It allows every kind of trick that we had so far patched into biblio or implemented with our hooks. Even the "secondary = editor" is no longer a problem. We have the "Author" fieldset sharing our three non-editor author types, and the "Secondary author" fieldset for the editor types, so everything with bibtex import/export and editors works fine without any additional stuff.

You really solved all this in a very elegant way and I'm sorry I was moaning around instead of realizing the new possibilities :-)

rjerome’s picture

Good, another satisfied customer :-) Don't feel bad, this is completely undocumented so you really had no way of knowing what capabilities were available.

Robert Haschke deserves most of the credit, he put an awful lot of work into this feature.

rjerome’s picture

Oh, and speaking of documentation, I just found out today that the D6 upgrade of d.o completely toasted all the documentation for contributed modules and they still (almost 4 weeks later) haven't got it straightened out yet! You'll see what I mean if you follow the Documentation link on the main Biblio module page.

I found this out because I have a new volunteer working on documentation and they went to modify the existing documentation only to find there was only one page (out of a few dozen) left :-((

Frank Steiner’s picture

I see :-(

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.