SiteSearch

Adds global search capabilities to October CMS

Back to SiteSearch Support

beenen445
beenen445

I've used this plugin in a project I'm currently working on, but it seems I've found an error when having custom providers. The following code (found in classes/providers/ResultsProvider.php on line 94) seems to be related to the issue.

if ($provider === null) { $result->provider = $this->displayName; }

When changed to the code below it seems to work as intended.

if ($provider === null) { $result->provider = $this->displayName; } else { $result->provider = $provider; }

Last updated

OFFLINE
OFFLINE

Hi

What exactly is the problem you're experiencing? What doesn't work as expected?

beenen445
beenen445

I've been trying to access the provider from my Twig view for a certain search result. This variable seems to be empty when it's a custom provider.

I am extending the plugin using the code down below. Note the custom 'Article' provider.

Event::listen('offline.sitesearch.query', function ($query) { return [ 'provider' => 'Article', 'results' => [/* results placeholder */ ], ]; });

Next I try to use custom styling for my search results.

{% for searchResult in searchResults.results %} {% partial "search/_" ~ searchResult.provider result=searchResult %} {% endfor %}

In this example the searchResult.provider is empty when it reaches the 'Article' results.

Last updated

OFFLINE
OFFLINE

I've just released version 1.2.5 where this bug is fixed.

Thanks for pointing it out! Let me know if the problem still exists.

1-4 of 4