Problem/Motivation

The current filter settings form is confusing, leading multiple users to report alter hooks not working because of a missed duplicate checkbox. There are currently two checkboxes that have to both be checked for the hook to work, and yet they say the exact same thing and the second one is checked by default. Because of the layout of the page, the first one (unchecked by default) is frequently missed.

That second checkbox says "always checked" next to it, which doesn't make any sense in and of itself, but also distracts users away from the actual functional checkbox in the list above. WTF?

Proposed resolution

We should remove the second checkbox in the vertical tab and further have the first checkbox above the tabs use the states API to only show the tab below when the checkbox above is checked. Then, the vertical tab becomes merely an information pane, but I think that's fine, especially if it only shows when it's configured correctly to be meaningful.

Remaining tasks

Usability review and patch needed.

User interface changes

Modification to vertical tabs using states linked to filters checkboxes above.

API changes

None

Original report by johnish

hook_facet_items_alter() never fires. I have cleared cache and rebuilt the registry and the step through debugger still doesn't stop on it.

function veritas_facet_items_alter(&$build, &$settings) {
  if ($settings->facet == "my_facet_name") {
    $build[1]['#markup'] = t('My Custom Title');
  }
  if ($settings->facet == "item_details") {
    foreach($build as $key => $item) {
      $build[$key]["#markup"] = drupal_strtoupper($item["#markup"]);
    }
  }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnish’s picture

I see in filter_rewrite_items.inc that their is a form? I looked around and I can't find a configuration for this module.

seanr’s picture

Category: Bug report » Support request

Make sure you have checked the box for "Rewrite facet items via callback function" on the facet's filter settings. I missed that as well - the box in the verticl tabs group was checked, but the one in the listing above was not.

bserem’s picture

Category: Support request » Bug report

disregard this comment

bserem’s picture

Category: Bug report » Support request
devd’s picture

Category: Support request » Bug report
Issue tags: +alter
FileSize
30.67 KB

I am also facing the same issue the following hook never executed.
hook_facet_items_alter().

seanr’s picture

There are two checkboxes that have to be checked. It's pretty horrible UI, to be honest. See attached.

devd’s picture

Category: Bug report » Support request
Issue tags: -alter

Thanks Robertson,

It is working fine.

Thanks & Regard
Devendra

seanr’s picture

Title: hook_facet_items_alter() never gets executed » Improve usability of facet filters screen to eliminate confusion around hook_facet_items_alter()
Version: 7.x-1.1 » 7.x-1.x-dev
Component: Code » User interface
Category: Support request » Task
Issue summary: View changes
Issue tags: +Usability, +DrupalWTF, +Needs usability review

Updated issue to propose a UX task to eliminate confusion around this form.

118218’s picture

Where is the filter settings form located?? I am going crazy trying to find it!

robbertnl’s picture

@#9 you can find it via SearchIndex ->Facets -> Configure Filters -> tab Rewrite facet items via callback function

thePanz’s picture

Component: User interface » Documentation
Assigned: Unassigned » thePanz
Status: Active » Needs review
FileSize
3.06 KB

Patch attached, added API documentation and settings form cleaned.
Please review

  • thePanz committed 8630e37 on 7.x-1.x
    Issue #2146297 by thePanz: Improve usability of facet filters screen to...
thePanz’s picture

Status: Needs review » Fixed

Latest patch got committed, will be included in the next 7.x-1.3 module release

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.