Flarum 全站搜尋功能(含中文)
1.MySqlFulltextLikeModeDriver.php
首先在 \vendor\flarum\core\src\Core\Search\Discussion\Fulltext\ 資料夾中,建立新檔案為 MySqlFulltextLikeModeDriver.php 。
MySqlFulltextLikeModeDriver.php
2. SearchServiceProvider.php
打開 \vendor\flarum\core\src\Core\Search\SearchServiceProvider.php
LINE 30
改成 👇👇👇
參考網址:https://gaobukai.com/flarum/86.html
1.MySqlFulltextLikeModeDriver.php
首先在 \vendor\flarum\core\src\Core\Search\Discussion\Fulltext\ 資料夾中,建立新檔案為 MySqlFulltextLikeModeDriver.php 。
MySqlFulltextLikeModeDriver.php
<?php namespace Flarum\Core\Search\Discussion\Fulltext; use Flarum\Core\Post; use Flarum\Core\Discussion; class MySqlFulltextLikeModeDriver implements DriverInterface { /** * {@inheritdoc} */ public function match($string) { $discussionTitleIds = Discussion::where('title', 'like', "%$string%") ->lists('id'); $discussionIds = Post::where('type', 'comment') ->where('content', 'like', "%$string%") ->lists('discussion_id', 'id'); $relevantPostIds = []; foreach ($discussionTitleIds as $discussionId) { $relevantPostIds[$discussionId][] = 0; } foreach ($discussionIds as $postId => $discussionId) { $relevantPostIds[$discussionId][] = $postId; } return $relevantPostIds; } }
2. SearchServiceProvider.php
打開 \vendor\flarum\core\src\Core\Search\SearchServiceProvider.php
LINE 30
'Flarum\Core\Search\Discussion\Fulltext\MySqlFulltextDriver'
改成 👇👇👇
'Flarum\Core\Search\Discussion\Fulltext\MySqlFulltextLikeModeDriver'
參考網址:https://gaobukai.com/flarum/86.html
PHP remove HTML and PHP tags from string
回覆刪除how to retrieve encrypted password from database in php
Text to speech in PHP
PHP get and set cookie
How to retrieve data from mongodb using php
PHP copying or moving a file