LoginSignup
1
0

More than 5 years have passed since last update.

Craft CMS でファジー検索を有効にする

Posted at

Craft CMS でエントリなどを検索する場合、管理画面やテンプレートを問わず、デフォルトでは完全一致するデータしかヒットしない。

前後に他のテキストを含むなど、ファジー検索を有効にするためには config/general.phpdefaultSearchTermOptions を追記する。

config/general.php
<?php

return [
    // Global settings
    '*' => [
        // ファジー検索を有効化
        'defaultSearchTermOptions' => array(
            'subLeft' => true,
            'subRight' => true,
        ),
    ],

    // Dev environment settings
    'dev' => [
        // (中略)
    ],
];

この例では * の配列に定義しているため、 dev staging production など .env で指定する環境を問わず有効になる。

参考

Enabling Fuzzy Search by Default | Craft CMS
https://craftcms.com/guides/enabling-fuzzy-search-by-default

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0