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.
Is there a way the module could use a setting in the admin to prevent the sort block from hiding if there is only 1 result? I have a boss that would prefer the consistency of the block being there even if it is of no practical use.
Comment | File | Size | Author |
---|---|---|---|
#10 | apachesolr-expose-minimum-sort-1421510-10.patch | 2.39 KB | johnrosswvsu |
#9 | apachesolr-1421510-allow_the_sort_block_to-9.patch | 2.83 KB | dooug |
#8 | apachesolr-expose-minimum-sort-1421510-8.patch | 2.39 KB | kaidjohnson |
Comments
Comment #1
Nick_vhI guess it is easier to convince your boss that it would be bad practice ;-)
Right now I don't see any way to do this aside from redefining the block again in custom code
Logic that prevents this from showing if there are less than 2 results.
Comment #2
Daemon_Byte CreditAttribution: Daemon_Byte commentedYou can present a solid case with tonnes of evidence but they want it their way and it has to be that way no matter how silly that might be. I found that code but I was wondering if perhaps the 2 could be moved into the settings page rather than hard coded.
Comment #3
Nick_vhI'd suggest you make it a variable_get so it would be easy to change, but no need to add a UI for this.
Comment #4
Daemon_Byte CreditAttribution: Daemon_Byte commentedI removed the if in my code as I need it always, I just thought there might be others that would like the ability to always have a sort box and they don't have the skills to maintain patch files.
Comment #5
Nick_vhWell, as I suggested? Please make a patch that sets this number as a variable_get? This way developers can easily adjust this number with a custom module
Comment #6
Daemon_Byte CreditAttribution: Daemon_Byte commentedArh I'm with you now. Sorry I didn't get what you meant. I shall do that in a couple of days when I have a spare minute.
Comment #7
Nick_vhComment #7.0
Nick_vhtypo
Comment #8
kaidjohnson CreditAttribution: kaidjohnson commentedWe're working on a project right now where this functionality would be handy. Because we now have contextual pages/blocks, I've exposed this setting in the advance settings area of the search page edit forms. This setting is then retrieved in the sort block handler.
I don't think there's any reason to require an update to set this value. If the value isn't set, it will always default to 2. Otherwise it uses the user's preference.
This patch also cleans up a few code redundancies found in that sort block handler. Namely:
* Setting $response to NULL is unnecessary. If (empty($response)) will handle an unset value just fine.
* Checking $delta == 'sort' is redundant as it has already been checked two lines above.
Comment #9
dooug CreditAttribution: dooug at Promet Source commentedRe-rolled patch against latest 7.x-1.x.
Comment #10
johnrosswvsu CreditAttribution: johnrosswvsu as a volunteer and at Promet Source commentedAdding a clean patch against the latest stable version.