iqnection-pages/searchresultspage

2.1.3 2021-02-05 20:26 UTC

This package is auto-updated.

Last update: 2024-09-07 14:51:41 UTC


README

搜索所有页面和数据对象(拥有正确索引的)

所有包含名为 "SearchFields" 的全文索引的 DataObject 子类都将被搜索。以下是如何指定您想要搜索的数据库列:

private static $indexes = [
	'SearchFields' => [
		'type' => 'fulltext',
		'columns' => ['MyField1', 'MyField2'],
	]
];

您还需要按照以下方式设置表引擎:

private static $create_table_options = [
	MySQLSchemaManager::ID => 'ENGINE=MyISAM'
];

构建搜索表单,将搜索输入的名称设置为 "s",并将表单提交到搜索页面动作 "results"。

<form method="get" action="{$SearchPage.Link(results)}">
    <input type="search" name="s" value="" />
    <input type="submit" value="Search" />
</form>

更多信息请参阅:https://docs.silverstripe.org/en/4/developer_guides/search/fulltextsearch/