I would like to suggest splitting exposed filters and exposed sort.

Placing sort inside a seperate block or being able to attach it before a view page display. In my opinion this would greatly improve user experience.

Maybe this couid be made optional?

Comments

ferahl’s picture

Would also like this feature or find out how to do it

tahiticlic’s picture

+1 for this functionnality.

In my own use case :

  • I use a view to render search api results
  • I've a fulltext exposed filter which is located on top of each pages
  • I would be very pleased to have a block with exposed sorts on search results page, located in a sidebar

I'll crosspost on Views issues list, since this is more Views related (I tought it was a views issue here...)

tahiticlic’s picture

In fact, you can separate those blocks quite easily :

  1. define all your filters and sorts in your view page, and expose them
  2. duplicate the page display inside the view, do not change the path, pages must use the same path
  3. now, use templates to reduce the display to what you want and/or use CSS to hide filters or sorts
  4. et voilà!
deggertsen’s picture

@tahiticlic Seems like a brilliant solution (thought not so elegant). Is there any chance this would cause any performance issues?

deggertsen’s picture

So I figured out a problem with the "solution" in #3. When one exposed filter is used from one view display and then the other is used from the second display, all of the filters selected from the first display are forgotten in favor of the latter.

Now is appears that this problem is only happening when the sort order or the items per page are changed by one of the exposed filter. As long as you only stick to changing filter criteria it seems like this is working alright. I have tested with and without AJAX enabled and with limited testing it appears that there are more issues with AJAX, but I'm not sure.

Anyways, it would be nice to see this in Views, but it is likely a views issue rather than a Better Exposed Filters issue. I'm looking for potential duplicate issues and I may come back and reassign this issue depending on what I find.

deggertsen’s picture

Potential duplicate issues:

#1337580: How to split the exposed filters to separate blocks?
#1420332: How to separate exposed filters and sort? - I like the panels solution used here assuming it works. My initial test has not been successful.

Exploratus’s picture

I find the sort exposed filters in views to be very unintuitive. It would be great to be able to split them and have a more traditional exposed search filter, and then a sort filter as a separate block.

berliner’s picture

Title: Seperate exposed sort from from exposed filterblock » Separate exposed sort form from exposed filter block

See #1337580-9: How to split the exposed filters to separate blocks? for a sandbox module that tries to solve this problem.

mikeker’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)
Issue tags: -exposed sort

Issue queue cleanup... My apologies for taking so long to address this issue!

Sorry, but this is beyond the scope of BEF. It would be better if Views were to provide separate blocks for each of these items -- then all Views-related modules could benefit from it. And it sounds like there is a possible solution in #8 (thanks for adding that, @berliner!), so I'm closing this as won't fix.

Sander Wemagine’s picture

The solution I used is MultiBlock.

  1. Download and enable MultiBlock
  2. Create the exposed form view block in Views as usual
  3. Create an extra instance of that exposed form with MultiBlock
  4. Edit that instance with template or form_alter hooks (or CSS but thats not the preferred way to go of course).

And your done!

jphelan’s picture

The mefibs (More exposed forms in blocks) module does this very well.
https://www.drupal.org/project/mefibs

Alejo D’s picture

Hello,

Any solution for this on D9 ? because that approach only works on D7.

Thanks.

aharown07’s picture

The method in #3 works in D9.

Some further explanation may be helpful. For some of us, this is counterintuitive.

Here's what I just did with one site.

I wanted a search input field on without any sorting, but wanted the sort options included on the search result page only. I already had the search result View created, and two block instances: one for and one for the result page. (Did that because I wanted them in different regions).

But they both included the exposed filter sort options.

(Side note: since I already had a separate instance of the block on in a different region, I'm pretty sure I could have used display: none in the CSS with the right selector to make sort invisible. But since this particular page is likely to see a good bit of traffic, it seems better to not render the sort stuff at all)

  1. In the View, duplicate the search result page display. I duplicated it as display type=page and left it with the same path. I called the new display "main front"
  2. In the sorting section of 'main front,' I disabled the "expose" options for the sort. Saved the View.
  3. In block layout, added the new block to the desired region, with visibility only to

Cleared all the caches (maybe not necessary) and tested. At that point I had two blocks on front, so disabled the old one. The new one has no sorting exposed. Search still lands on the same search results page.

I'm sure there's a way to use some kind of "if on front, don't print this sort bit" logic in a twig template, so that's also an option. But I'm more familiar with Views than with twig work.

hongqing’s picture

This is exactly what I am looking for. #3 and #13 are the solutions with Drupal 9. More details as below:

1. create a search result page with FILTER CRITERIA and SORT CRITERIA exposed with Exposed form in block:No.
2. Duplicate this page. Uncheck Expose this sort to visitors, to allow them to change it in SORT CRITERIA, and Exposed form in block:Yes.
3. Place the exposed form from the page duplicated in the block region.