I have a view which displays a list of products with exposed filter for the sort criteria. I want to sort the products by PRICE and by DATE. I've done that already with no problem.
My issue is that I need to "order by" text to be specific for each sort criteria like this:
Price (Highest/Lowest)
Date (Newest/Oldest)
Instead of:
Price (Ascending/Descending)
Date (Ascending/Descending)

Is this possible?

Comments

dawehner’s picture

Status: Active » Fixed

Yes, you can configure it under the exposed form settings.

ismail cherri’s picture

I'm sorry, I think I didn't explain my issue very well...
I need to change the text for each sort criteria. I mean to have a descriptive text corresponding to each sort criteria.
e.g. highest and lowest for price, heaviest and lightest for weight, recent and old for date etc...

Right now, I can only assign one descriptive text for ascending and another one for descending.

Status: Fixed » Closed (fixed)

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

halloffame’s picture

Status: Closed (fixed) » Active

Looking for the exact same thing.

@necromancerfinal How did you go about doing this?

dawehner’s picture

You probably have to build some better ui, because with having two select-boxes different texts doesn't actually make sense.

halloffame’s picture

@dereine I'm looking into removing the 'order' select list instead for the meantime while looking for better solution. Can you please point me to the right themeable function where I could do this? Thanks.

dawehner’s picture

You could use the views-exposed-form.tpl.php

ismail cherri’s picture

@evilgenius
I used Better Exposed Filters.
With this module you can combine the sort criteria and the sort order text in a single dropdown list. But I still can't change the sort order text for each one :(

halloffame’s picture

I just got rid of the order select list and say if I have 'date' sort and wanted to offer both descending and ascending I would create two sort criteria and labeled them 'View from newest to oldest and 'View from oldest to newest'.

jarchowk’s picture

To do this I used Better Exposed Filters then changed:

$options["$by_key $order_key"] = "$by_val $order_val";

to

$options["$by_key $order_key"] = t("$by_val $order_val");

Line 346 in better_exposed_filters_exposed_form_plugin.inc

Then used String Overrides.

maxime_sbk’s picture

Can someone submit a patch for this?

couturier’s picture

This issue is closed. If you really want a patch, re-open.

jaclayton’s picture

Issue summary: View changes

Yes, this issue is closed. But in case someone comes along...

I ended up using jQuery to fix this, dropping a bit of code into the footer of the view to change the dropdown options we're using. I should add that we're using Better Exposed Filters to combine date, price, and title options.

<script type="text/javascript">
(function($) {
  $("#edit-sort-by").change(function() {
  var sortOrder = $("#edit-sort-by option:selected").text();
  if(sortOrder=="Title"){
    $("#edit-sort-order option[value='ASC']").text("A-Z");
    $("#edit-sort-order option[value='DESC']").text("Z-A");
  } else if (sortOrder=="Date Added") {
    $("#edit-sort-order option[value='ASC']").text("Oldest First");
    $("#edit-sort-order option[value='DESC']").text("Newest First");
  } else if (sortOrder=="Price"){
    $("#edit-sort-order option[value='ASC']").text("Lowest to Highest");
    $("#edit-sort-order option[value='DESC']").text("Highest to Lowest");
  }
});
$("#edit-sort-by").trigger("change");
}(jQuery));
</script>

Hopefully fairly self-explanatory - check to see what the selected value is and then alter the dropdown text appropriately. Obviously this isn't using any regionalisation of text, it's strictly a single-language solution.

The final call to triger("change") simulates the selection of the current option so that when the page loads the user isn't presented with the default "Asc/Desc" values.

If this has been superceded by something that is language-aware and simpler for the end-user to implement, I'd love to know.

mustanggb’s picture

Status: Active » Closed (outdated)

Closing this as outdated to tidy up a bit around here. If you're still having problems with the latest release please create a new issue.