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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nick_vh’s picture

I 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.

if (empty($response) || ($response->response->numFound < 2)) {
  return;
}
Daemon_Byte’s picture

You 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.

Nick_vh’s picture

I'd suggest you make it a variable_get so it would be easy to change, but no need to add a UI for this.

Daemon_Byte’s picture

I 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.

Nick_vh’s picture

Well, 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

Daemon_Byte’s picture

Arh 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.

Nick_vh’s picture

Status: Active » Needs work
Nick_vh’s picture

Issue summary: View changes

typo

kaidjohnson’s picture

Version: 7.x-1.0-beta9 » 7.x-1.x-dev
Assigned: Unassigned » kaidjohnson
Issue summary: View changes
Status: Needs work » Needs review
FileSize
2.39 KB

We'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.

dooug’s picture

Re-rolled patch against latest 7.x-1.x.

johnrosswvsu’s picture

Adding a clean patch against the latest stable version.