Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To allow for BEF to display the exposed sort options as Links, Toggle Links or Radio buttons you have to select the "Expose sort order" option. But when you just want a link to sort only one way, for example "new item on top" you don't need the sort order exposed.
The following patch fixes this by allowing to use the "Display exposed sort options as" regardless of the exposed sort order.
Comments
Comment #1
dazz CreditAttribution: dazz commentedComment #2
jfrederick CreditAttribution: jfrederick commentedPatch #1 works, but introduces PHP warnings such as, "
Notice: Undefined index: #name in theme_select_as_links() (line 460 of /var/www/career/sites/all/modules/contrib/better_exposed_filters/better_exposed_filters.theme).
"This is because the module previously assumed that if you were displaying your exposed sort options as links, then both 'sort by' and 'sort order' form elements must have been present. The module then manipulates those specific form elements. However, since this patch makes it possible to theme the form elements as links without including 'sort order', we have to ensure the individual form elements exist before manipulating them.
This patch also omits from #1 some undesirable spacing issues and changes that appear unrelated to this issue.
Comment #3
brunorios1 CreditAttribution: brunorios1 commented#2 worked for me, but shows warning in panels:
Notice: Undefined index: path in better_exposed_filters_exposed_form_plugin->exposed_form_alter() (line 817 of /var/www/myproect/docroot/sites/all/modules/contrib/better_exposed_filters/better_exposed_filters_exposed_form_plugin.inc).
Comment #4
brunorios1 CreditAttribution: brunorios1 commentedComment #5
interdruper CreditAttribution: interdruper commented#2 works fine for me. The issue reported in #3 may be unrelated to this patch, it seems so watching the code:
@brunorios1, could you confirm that the notice in your particular view only appears after applying the patch ?
Comment #6
phamkhaclam90@gmail.com CreditAttribution: phamkhaclam90@gmail.com commentedThis is the result when I apply patch in #2:
The code must be:
$form['sort_bef_combine']['#bef_path'] = isset($this->display->display_options['path']) ? $this->display->display_options['path'] : '';
instead of:
Please check this, I'm using version 7.x-3.x-dev, date 2014-Sep-01
Comment #7
quotesBro CreditAttribution: quotesBro commentedre-roll against latest dev (2014-Nov-03)
Comment #8
quotesBro CreditAttribution: quotesBro commentedpatch works well for me.
Comment #9
szeidler CreditAttribution: szeidler commentedWorks also fine for dev (2014-Nov-13). Should definitely be committed.
Comment #10
mikeker CreditAttribution: mikeker commentedApologies for taking so long to get to this issue.
Can't the original request be done by rewriting the output of the sort options you don't want to NULL? Eg: you have "post date" and "title" set as exposed sorts. You can set the rewrite text to be:
To only have the options "Newest first" and "Alphabetical" show.
Or am I missing something? Thanks.
Comment #11
jfrederick CreditAttribution: jfrederick commentedSince the module exposes the option to display the sort options as links in the admin UI, it seems to me that no code or Views re-rewriting should be necessary to perform that advertised function. I think exposed sorts without exposed sort direction is a common-enough use case to warrant making it easy to accomplish. I am thinking of 'Latest' Views, 'Most Popular' views, etc, where the reverse sort seems pretty uninteresting to a site user.
Alternatively, there could be help text explaining that one must also expose the sort direction for the links to work, and help text echoing the solution in #10. That sounds unintuitive to me, as the patch builds the feature into the UI rather than having to add and then rely on people reading a how-to.
@mikeker, do you see downsides to incorporating the patch? Thanks.
Comment #12
mikeker CreditAttribution: mikeker commented@jfrederick: Thanks for the explanation -- I think the use-case you describe is valid and you make a good point about "making it easy to accomplish," which is what this module is all about. OK, I'm open to adding this -- for the record, my main objection was adding more complexity to the already complex UI code.
However, I get
Notice: Undefined index: #options in form_process_radios() (line 3017 of <snip>\includes\form.inc).
when I use radio buttons for the exposed sort settings.
Comment #13
lachezar.valchev CreditAttribution: lachezar.valchev commentedHi,
Here is re-rolled the patch from #7 so that it works with the latest stable version released yesterday.
Regards,
Lachezar
Comment #14
lachezar.valchev CreditAttribution: lachezar.valchev commentedHi,
Changed the issue status to Needs Review in order to check the re-rolled patch.
Regards,
Lachezar
Comment #15
jenlamptonI'm not sure this patch is still necessary, as I am able to expose the sort options as links without also selecting 'Expose sort order'. If that's not the problem this patch is aiming to correct, would someone please update the issue summary?
Comment #16
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedI'm using BEF 7.x-3.2 and with deactivating the
Expose sort order
checkbox everything work like expected, too.4 Can someone, who has reported the issue, can verify that?Comment #17
shahidaali CreditAttribution: shahidaali commentedThis issue is generated because
#options
missing in sort_order element. Added following code fixed the issue.On line
855
inbetter_exposed_filters_exposed_form_plugin.inc
after applying patch from #13Comment #18
svetoslav.dragoev CreditAttribution: svetoslav.dragoev commentedRe-roll of #13 against the release from 25 Oct 2017 - dev. Also compatible with version 7.x-3.5.
Comment #19
svetoslav.dragoev CreditAttribution: svetoslav.dragoev commentedFix in patch #18, removed wrong diff paths, set them to root.
Comment #20
Neslee Canil PintoHi, there will be no more future development for 7.x branch. If you see this issue in 8.x, feel free to file an issue. Closing this as Closed(wont fix).