Hi,
to be able to use facet id and/or raw value for theme overriding and css for the facet items in the facets summary block, you would need the facet id + the facet item's raw value during the creation of the renderable facet result items.
Included is a patch which provides this.
(The patch does not include a change of the facet result item template as this can be easily overridden in any custom theme.)

I use this patch to be able to add selected facet values to the facets summary block 'manually' when they have 0 results. My configuration does not allow my facets to show items with minimum count 0 but I do need them in the facets summary block. Now , using the facet id and raw value in the rendered facet result item in the facets summary block, I can detect which active facet items are missing in the facets summary block by comparing the facet result items in the summary block with the selected facet items from the query facet parameters.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jummonk created an issue. See original summary.

borisson_’s picture

Status: Active » Needs review

Setting to needs review so the testbot hopefully picks this up.

borisson_’s picture

It didn't, so reuploading.

Status: Needs review » Needs work

The last submitted patch, 3: facet-id-in-facet-result-item-1.patch, failed testing.

borisson_’s picture

Issue tags: +beta blocker

Doing this will break the API, so we should do this before we tag the first beta.

borisson_’s picture

Status: Needs work » Needs review
FileSize
20.43 KB

Fixes this in the tests as well, would like to get reviews on this.

jeni_dc’s picture

The patch applied for me, but "with fuzz" against the latest dev, so I've rerolled the patch and it's now applying cleanly.

I needed similar functionality to have the facet ID in the facets_result_item and facets_item_list variables arrays to be able to use hook_theme_suggestions_HOOK_alter() to use different templates for certain facets. So I've also included changes to make sure they're available.

In facets_theme() facets_result_item contained facet_id and raw_value from the previous patch, but they were not populated, and I've added facet_id to facets_item_list. The facet ID was actually already in facets_item_list attributes, but checking against an attribute just seemed messy so adding a new variable that only contained the facet ID keeps things consistent between the two.

Those variables are now populated in WidgetPluginBase.php.

Status: Needs review » Needs work

The last submitted patch, 7: provide_facet_id_and-2855320-7.patch, failed testing. View results

borisson_’s picture

Status: Needs work » Needs review
FileSize
20.42 KB

Reroll of #6 where there actual changes in #7 as well?

borisson_’s picture

There was, this includes those changes.

borisson_’s picture

Status: Needs review » Needs work

Back to needs work, the tests need to be green for this to pass.

borisson_’s picture

Status: Needs work » Needs review
FileSize
12.89 KB
32.87 KB

All tests should be green now. At least the unit/kernel tests are.

StryKaizer’s picture

Assigned: Unassigned » StryKaizer
Status: Needs review » Needs work
Issue tags: +Vienna2017

Looks great.
Lets include the entire facet object instead for more flexibility.

StryKaizer’s picture

Status: Needs work » Needs review
FileSize
38.55 KB
40.76 KB

Status: Needs review » Needs work

The last submitted patch, 14: provide_facet_id_and-2855320-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

StryKaizer’s picture

Status: Needs work » Needs review
FileSize
43.28 KB
6.4 KB
StryKaizer’s picture

FileSize
43.46 KB
725 bytes

The last submitted patch, 16: provide_facet_id_and-2855320-16.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 17: provide_facet_id_and-2855320-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

StryKaizer’s picture

Hooray, Drupal 8.5 broke our tests...

borisson_’s picture

Status: Needs work » Needs review
FileSize
2.43 KB
44.29 KB

Testfix + cs fixes.

Status: Needs review » Needs work

The last submitted patch, 21: provide_facet_id_and-2855320-21.patch, failed testing. View results

borisson_’s picture

Status: Needs work » Needs review
FileSize
2.43 KB
42.57 KB

I made a mistake when rolling the previous patch, updated version attached.

StryKaizer’s picture

Status: Needs review » Reviewed & tested by the community

  • StryKaizer committed 6cbf156 on 8.x-1.x authored by borisson_
    Issue #2855320 by borisson_, StryKaizer, jummonk, jeni_dc: Provide facet...
StryKaizer’s picture

Status: Reviewed & tested by the community » Fixed
StryKaizer’s picture

Assigned: StryKaizer » Unassigned

Status: Fixed » Closed (fixed)

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