SiteSearch

Adds global search capabilities to October CMS

Back to SiteSearch Support

Responsive
Responsive

Hi there,

Love your plugin!

Any plans to support October v3 and in particular Tailor generated content?

Cheers,

Cy

OFFLINE
OFFLINE

Yes, absolutely! I just did not find the time to implement the feature yet, but it is on the roadmap.

In the meantime, you can implement it yourself in our app/Provider.php:

    Event::listen('offline.sitesearch.query', function ($query) {
            $controller = \Cms\Classes\Controller::getController() ?? new \Cms\Classes\Controller();

            $items = \Tailor\Models\EntryRecord::inSection('Your\Section')
                ->applyPublishedStatus()
                ->where(function ($q) use ($query) {
                    $q->where('title', 'like', "%{$query}%")
                        ->orWhere('content', 'like', "%{$query}%")
                        ->orWhere('some_other_field', 'like', "%{$query}%");
                })
                ->get();

            $results = $items->map(function ($item) use ($query, $controller) {
                $relevance = mb_stripos($item->title, $query) !== false ? 2 : 1;

                return [
                    'title' => $item->title,
                    'text' => $item->content,
                    'url' => $controller->pageUrl('target-page-filename', ['slug' => $item->slug]),
                    'thumb' => optional($item->image)->first(),
                    'relevance' => $relevance,
                ];
            });

            return [
                'provider' => 'Project',
                'results' => $results,
            ];
        });

1-2 of 2