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.
Comment | File | Size | Author |
---|---|---|---|
#23 | provide_facet_id_and-2855320-23.patch | 42.57 KB | borisson_ |
Comments
Comment #2
borisson_Setting to needs review so the testbot hopefully picks this up.
Comment #3
borisson_It didn't, so reuploading.
Comment #5
borisson_Doing this will break the API, so we should do this before we tag the first beta.
Comment #6
borisson_Fixes this in the tests as well, would like to get reviews on this.
Comment #7
jeni_dc CreditAttribution: jeni_dc commentedThe 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.
Comment #9
borisson_Reroll of #6 where there actual changes in #7 as well?
Comment #10
borisson_There was, this includes those changes.
Comment #11
borisson_Back to needs work, the tests need to be green for this to pass.
Comment #12
borisson_All tests should be green now. At least the unit/kernel tests are.
Comment #13
StryKaizerLooks great.
Lets include the entire facet object instead for more flexibility.
Comment #14
StryKaizerComment #16
StryKaizerComment #17
StryKaizerComment #20
StryKaizerHooray, Drupal 8.5 broke our tests...
Comment #21
borisson_Testfix + cs fixes.
Comment #23
borisson_I made a mistake when rolling the previous patch, updated version attached.
Comment #24
StryKaizerComment #26
StryKaizerComment #27
StryKaizer