2

I have a view with the following sort handlers:

  • price (exposed, asc/desc, default=asc)
  • stock (desc)

I would like to have a third option for price so that it can be inactive/asc/desc, with "inactive" being the default.

So by default it sorts by stock availability (or any other sort handlers I may configure in the future), and only if the user chooses "cheapest first" it will sort by price.

(I am going to use Better exposed filters to display the sort options as links, but this is secondary)

5
  • Playing around with the filter order (Put "stock" on top of "price") might fix your problem.
    – Matt
    Commented Mar 24, 2014 at 17:23
  • Won't this give "stock" priority over price? That is, if one item has stock=10 and another has stock=5, won't the stock=10 item be displayed at the top independent of price?
    – donquixote
    Commented Mar 24, 2014 at 17:31
  • I also noticed it is possible to expose "stock", and use better exposed filters to combine all in one select dropdown and add custom labels. But I don't fully understand the logic if there is more than one exposed sort.
    – donquixote
    Commented Mar 24, 2014 at 17:50
  • Actually this did help! Expose the stock sort, put it at the top, then use BEF to put other names on the options. BEF also allows to hide some options.
    – donquixote
    Commented Mar 25, 2014 at 13:14
  • This is going to be lost bounty :( meta.drupal.stackexchange.com/questions/1081/…
    – donquixote
    Commented Mar 31, 2014 at 17:37

1 Answer 1

3

Things to learn:

  • If more than one sort option is exposed, then only one of them will be active at a time.
  • The first of all exposed sort option will be active by default, the others will be inactive by default.
  • The non-exposed sort options will always be active. But if you put them below the exposed sort options, they will have a lower priority, obviously, so you might not see the effect.
  • One field can be used multiple times. E.g. one time exposed, another time not exposed.
  • BEF can be used to re-label the options.
  • BEF can be used to hide some sort options, by leaving the label empty.

Example sort configuration:

  1. stock, exposed, descending.
  2. amount, exposed.
  3. stock, descending. (not exposed)

Then in the BEF settings, "Advanced sort options", "Rewrite the text displayed":

Stock Desc|No sort
Stock Asc|
Price Asc|Cheapest first
Price Desc|Most expensive first
1
  • since this is the only answer i received, and it does work for me, i am accepting this
    – donquixote
    Commented Mar 30, 2014 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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