adair-creative/searching

该软件包最新版本(dev-master)没有可用的许可证信息。

一款易于使用且功能强大的搜索和分析工具

dev-master 2019-08-12 15:09 UTC

This package is auto-updated.

Last update: 2024-09-13 02:33:03 UTC


README

关于

一款灵活且功能强大的搜索工具,包括

  • CMS 分析
  • 搜索词路由
  • 非侵入式实现

安装

composer require adair-creative/searching

指南

基本用法

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);
			]);
		}
	}
}

术语链接

// ...

$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;
}

// ...

参考

AdairCreative\Searching

函数 search() : ArrayList

字符串|字符串数组 $from - 要搜索的模型

字符串|字符串数组 $fieldName - 要搜索的字段,如果数组项将映射到相应的模型

字符串 $query - 要搜索的值;已修剪并转换为小写

默认 null 术语链接 &$term - 指向第一个找到的术语的指针(如果没有,则为 null)

默认 false 布尔型 $useSubstitute - 当为 true 时,如果 $term 是替代类型,则将 $search 更新为替代值

AdairCreaitve\Searching\TermLink

字符串 $Term - 要覆盖的搜索术语

整数 $Type - 在覆盖时执行的操作

0 - 使用替代

1 - 使用重定向

字符串 $Substitute - 搜索值替代

函数 Redirect() : SiteTree