adair-creative / searching
A tool for easy and advanced search and analytical functionality
This package is auto-updated.
Last update: 2024-11-13 02:47:27 UTC
README
About
A tool for flexible and advanced search functionality including:
- CMS Analytics
- Search term routing
- Non-intrusive implementation
Installation
composer require adair-creative/searching
Guide
Basic Usage
use AdairCreative\Searching; class YourPage_Controller extends PageController { public function index(HTTPRequest $request) { if ($query = $request->getVar('q')) { return $this->customise([ "Results" => Searching::search(Product::class, "Title", $search); ]); } } }
Term Linking
// ... $link = null; $resources = Searching::search(Product::class, "Title", $query, $link, true); if ($link != null) { if ($link->Type == 1) return $this->redirect($link->Redirect()->Link()); else $query = $link->Substitute; } // ...
Reference
AdairCreative\Searching
function
search()
: ArrayListstring|string[]
$from
- The model(s) to search fromstring|string[]
$fieldName
- The field(s) to search from, if array items will map to corresponding modelstring
$query
- Value to seach with; trimmed and no-caseDefault null TermLink
&$term
- A pointer to the first found term (null if none)Default false bool
$useSubstitute
- When true, If$term
is of type substitute then update$search
to the substitute value
AdairCreaitve\Searching\TermLink
string
$Term
- the search term to override
int
$Type
- The action to perform on override0 - Use substitute
1 - Use redirect
string
$Substitute
- The search value substitute
function
Redirect()
: SiteTree