werkbot/werkbot-search

Provides search functionality with TNTSearch

Installs: 642

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Type:silverstripe-vendormodule

1.2.3 2023-12-21 20:05 UTC

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

A silverstripe search module that utilizes TNTSearch to index content.

Installation

composer require werkbot/werkbot-search

Requirements

Setup

Add the following extensions to Page

Page::add_extension(SearchableExtension::class);
PageController::add_extension(SearchControllerExtension::class);

You will need to run dev/build

Define getIndexQuery on Page

The Page::class will need to have a function getIndexQuery defined. Here is an example for Page:

/*
  Get Index Query
  Query used by search extension for indexing
*/
public function getIndexQuery(){
  return "SELECT
      concat(\"Page_\", SiteTree.ID) AS ID,
      SiteTree.ClassName,
      SiteTree.Title,
      SiteTree.Content
    FROM
      Page
    LEFT JOIN
      SiteTree
    ON
      SiteTree.ID = Page.ID
    WHERE
      SiteTree.ShowInSearch = '1'";
}

This is a simple query that is used by the indexer to index your content.

This function can be customized however you like and also can be added to DataObjects.

External Libraries

By default, the templates used here use classes provided by external css libraries. We suggest installing both for the best experience:

Usage