Looking for some pointers here. Using latest dev version of biblio from 2009-07-03.

I want to customize the default sort order for the searches. I see you can customize this in the admin settings where you set the default sort, but if I undertstand correctly, this will set all the orders to ascending or all of them to descending.

I would like the following default sort order:
author - ASC (i.e. start with A)
keyword - ASC (i.e. start with A)
title - ASC (i.e. start with A)
year - DESC (i.e. start with newest)

I see a couple places in biblio.pages.inc where I should probably be looking to edit this:
function biblio_build_query
switch - lines 148-178
switch - lines 357-371
function biblio_category_separator_bar
switch - lines 674-736

I assume that this needs to be done by hardcoding something into the biblio.pages.inc or biblio_theme.inc files. But my PHP skillz are pretty weak, and I'm not sure how to change the default sort attribute for just one of the search cases, or how to use some of the variables that biblio makes available.

Any suggestions?

Comments

rjerome’s picture

Yes, your on the right track, soon you will be able to use Views to completely customize your display without touching the code, but if you want to modify the existing code, you would have to make a couple of changes to biblio.pages.inc...

at lines 171 - 175 should look like this... (added third line)

    case 'year':
    default:
      $sort_attrib['order'] =   (isset($_GET['order'])) ? (($_GET['order'] == 'desc') ? 'desc' : 'asc') : 'desc';  // <------added this line
      $sortby = "ORDER BY b.biblio_year %s, b.biblio_date %s";
  } //end switch

lines 537 -542 should look like this... (added third line)

  ksort($sort_links);
  $content .= $tabs ? '<ul class="tabs secondary ">':'';
  if ($attrib['sort'] == 'year') $cur_order = $order;   // <-------------added this line
  foreach($sort_links as $key => $link) {
    $sort_links['options'] = array();
    $sort_links['options']['attributes'] = array("title"=>t("Click a second time to reverse the sort order"));

Then set the default sorting to ASC on the settings page and it should work the way you want.

pkiff’s picture

Thanks Ron, that solves the initial default behaviours just great!

The links all work the way I want now when you first arrive on the biblio page, though they don't quite behave in an intuitive way if a user continues to change the sort order by clicking on one after another -- they revert back to all ascending or all descending. But it looks like that problem exists in a similar way with the original dev version as well.

Your edits will work well for us just as they are until further Views integration is added.

We are working on the second phase of our site redesign. The first phase was the move to Drupal (launched in December). The second phase is basically our implementation of biblio. Looking forward to sharing what we've learned after we launch phase two.

Thanks for an outstanding module.

Phil.

Institute for Work & Health
www.iwh.on.ca

rjerome’s picture

Hey! A fellow Canadian (I'm in Ottawa).

The reason the seem a little wonky is that all the links assume the current sort order of the active link so when you toggle one they all change, maybe not such a bright idea, but there it is. The little patch I provided you messes with that a bit if sorting on the year field, so additional wonkyness may be added at no additional cost :-)

The site looks good, let me know if you have any problems.

Ron.

knopf’s picture

I would like to support that the sorting options should be more flexible. For example, I want to sort

- first descending by year of publication
- then descending by entry date

Right now, a new publication gets always listed at the bottom. That's not how many people list publications. The latest work should be on top. This only happens when a publication month is known.

Thanks.

bekasu’s picture

Status: Active » Closed (fixed)

Using views, you can mix your sorting keys as well as ascending or descending.
marking closed for now.
bekasu