brandcom/silverstripe-elemental-site-search-fluent

5.x-dev 2024-09-26 12:00 UTC

This package is auto-updated.

Last update: 2024-09-26 12:00:57 UTC


README

为 SilverStripe Elemental 模块提供基本站内搜索功能。它通过将元素区域的文本表示保存在 SiteTree 的额外字段中来工作。此版本基于 Fluent 在多语言环境中工作。

需求

使用方法

使用 composer 安装此模块

composer require brandcom/silverstripe-elemental-site-search-fluent

请确保在 _config.php 中未启用 FulltextSearchable

开发/构建

需要在数据库中添加一些索引。这通过运行 dev/build 来完成。

添加搜索表单

要添加搜索表单,请在模板中任何位置添加 $SearchForm

例如在 Header.ss 中

...
<div class="search-form">
    $SearchForm
</div>
...

覆盖模板(可选)

最后,如果您需要,可以覆盖结果页面的模板。

复制

vendor/brandcom/silverstripe-elemental-site-search-fluent/templates/Layout/Page_results.ss

到您的模板文件夹中,例如

app/templates/Layout/Page_results.ss

并根据您的需要进行修改。

清除缓存

然后最后,将 ?flush=1 添加到 URL 中,您应该会看到新的模板。