1. Go to this page and download the library: Download werkbot/werkbot-search library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* getIndexQuery
* This query is used when building the index
*
* @return string|boolean - FALSE if not set
*/
public function getIndexQuery()
{
$class = get_class($this);
$class = str_replace('\\', '\\\\', $class);
/*
Alternatively, just use the short class name of the current file
Example: "Page"
*/
$indexQueryDeclaringClassShortname = $this->owner->getIndexQueryDeclaringClassShortname();
return <<<SQL
SELECT
concat("{$indexQueryDeclaringClassShortname}_", SiteTree_Live.ID) AS ID,
SiteTree_Live.ClassName,
SiteTree_Live.Title,
SiteTree_Live.Content
FROM
Page
LEFT JOIN
SiteTree_Live
ON
SiteTree_Live.ID = Page.ID
WHERE
SiteTree_Live.ShowInSearch = '1'
AND
-- Keeps subclasses from re-indexing duplicates
SiteTree_Live.ClassName = '$class'
AND
SiteTree_Live.Content IS NOT NULL
SQL;
}
SearchableDataObject::add_extension(SearchableExtension::class); // MUST BE APPLIED FIRST for getIndexQuery to return SQL Query string.
SearchableDataObject::add_extension(SearchableDataObjectExtension::class); // Defines getIndexQuery SQL Query string.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.