承接 werkbot/werkbot-search 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

werkbot/werkbot-search

Composer 安装命令:

composer require werkbot/werkbot-search

包简介

Provides search functionality with TNTSearch

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

A silverstripe search module that utilizes TNTSearch to index content.

Installation

composer require werkbot/werkbot-search

Requirements

Setup

Add the following extensions to Page

Page::add_extension(SearchableExtension::class);
PageController::add_extension(SearchControllerExtension::class);

You will need to run dev/build

Define getIndexQuery on Page

The Page::class will need to have a function getIndexQuery defined. Here is an example for Page:

/**
 * 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;
}

This is a simple query that is used by the indexer to index your content.

This function can be customized however you like and also can be added to DataObjects.

Data Extensions

Note that if the getIndexQuery method is defined in a DataExtension, the SearchableExtension must be added before the extension that adds the method. Otherwise the method will return the default: false.

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.

External Libraries

By default, the templates used here use classes provided by external css libraries. We suggest installing both for the best experience:

Usage

统计信息

  • 总下载量: 2.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固