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)

  • Playing around with the filter order (Put "stock" on top of "price") might fix your problem. – Matt Mar 24 '14 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 Mar 24 '14 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 Mar 24 '14 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 Mar 25 '14 at 13:14
  • This is going to be lost bounty :( meta.drupal.stackexchange.com/questions/1081/… – donquixote Mar 31 '14 at 17:37
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
  • since this is the only answer i received, and it does work for me, i am accepting this – donquixote Mar 30 '14 at 22:56

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.