- Issue created by @klimp
Hi,
Thank you for the fix, it helped me.
I had to add a few elements to make it work, i post them here.
Fix warnings when parameters are empty
foreach ($results as &$result) { $url = $result->getUrl(); $params = $url->getOption('query'); // FIX : we need to make sure the array exists $params[$this->filterKey] = $params[$this->filterKey] ?? []; foreach ($params[$this->filterKey] as $index => $param) {
Override query_string when using block facets
I couldn't select the url processor when using facets as blocks. This overrides the processor, which is forced to query_string by default.
This could be further improved to allow dynamic selection of the url processor.Create a new facet Entity
namespace Drupal\facet_override\Entity; class Facet extends \Drupal\facets\Entity\Facet { /** * {@inheritdoc} */ public function getFacetSourceConfig() { $facet_source = parent::getFacetSourceConfig(); $facet_source->set('url_processor', 'query_string_fix'); return $facet_source; }
Create a hook to use this entity
(In facet_override.module)
function facet_override_entity_type_alter(array &$entity_types) { // Add the facet_override entity type to the list of entity types. if (isset($entity_types['facets_facet'])) { $entity_types['facets_facet']->setClass('\Drupal\facet_override\Entity\Facet'); } }