1

I have a view of Commerce products that, as is standard for e-commerce product listings, can be sorted by price or by date. I'm having trouble with the sort direction labels:

  • In the context of dates, "Ascending" or "Descending" is confusing unless you are used to thinking about time in terms of UNIX timestamps. Labels like "Newest" and "Oldest" are much more user-friendly to average users.
  • In the context of prices, labels like "Highest" and "Lowest" are most user-friendly.

"Newest"/"Oldest" is clearly nonsense in the context of price, while both "Ascending/Descending" and "Highest"/"Lowest" are confusing to average users in the context of dates. I need both highest and lowest options for the prices sort because it's a luxury goods store and some users want to browse the most premium options.

The trouble is, even with Better Exposed Filters module, I can only have one custom ascending or descending label.

Ideally, I'd like something like this:

Sort by

  • Date - Newest
  • Date - Oldest
  • Price - Highest
  • Price - Lowest

...but I'd also accept something that switches the labels in the sort order based on the selection in sort type.

I could roll my own javascript, but surely I can't be the first person to have this use case. Is there an existing solution?

2

There's a feature for this in using the Better Exposed Filters module through certain combinations of BEF settings:

  • Set "Display exposed sort options as" to anything except Toggle links, which seems to give strange results
  • Under "Advanced sort options", tick "Combine sort order with sort by"
  • Save, and see what strings it outputs by default for the labels. For example:

    • Price Highest
    • Price Lowest
    • Date listed Highest
    • Date listed Lowest
    • Copy these into the "Rewrite the text displayed" field, then for each one put a | then the intended label, for example:

.

Price Highest|Price - Highest
Price Lowest|Price - Lowest
Date listed Highest|Date - Newest
Date listed Lowest|Date - Oldest

It then outputs as intended

  • Price - Highest
  • Price - Lowest
  • Date - Newest
  • Date - Oldest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.