diff --git a/src/Widget/WidgetPluginBase.php b/src/Widget/WidgetPluginBase.php index 30b4f63..ad29e4c 100644 --- a/src/Widget/WidgetPluginBase.php +++ b/src/Widget/WidgetPluginBase.php @@ -238,7 +238,7 @@ abstract class WidgetPluginBase extends PluginBase implements WidgetPluginInterf protected function buildResultItem(ResultInterface $result) { $count = $result->getCount(); return [ - '#theme' => 'facets_result_item', + '#theme' => $this->getFacetResultItemThemeHook($result->getFacet()), '#is_active' => $result->isActive(), '#value' => $result->getDisplayValue(), '#show_count' => $this->getConfiguration()['show_numbers'] && ($count !== NULL), @@ -248,6 +248,23 @@ abstract class WidgetPluginBase extends PluginBase implements WidgetPluginInterf ]; } + /** + * Provides a full string of possible theme functions to try for a given hook. + * + * This allows the following template suggestions: + * - facets-result-item--WIDGET_TYPE--FACET_ID + * - facets-result-item--WIDGET_TYPE + * - facets-result-item + * + * @param FacetInterface $facet + * The facet you want to generate the string from + * + * @return string + */ + protected function getFacetResultItemThemeHook(FacetInterface $facet) { + return 'facets_result_item__' . $facet->getWidget()['type'] . '__' . $facet->id(); + } + /** * {@inheritdoc} */