fruitstudios/searchit
Composer 安装命令:
composer require fruitstudios/searchit
包简介
Configure powerful custom filters for an enhanced search experience in the Craft CMS control panel.
关键字:
README 文档
README
Searchit plugin for Craft CMS 3
Configure powerful custom filters for an enhanced search experience in the Craft CMS control panel. Harness the power of twig and element queries to create endless filtering options. Keep your clients happy!
See it in action...
Requirements
This plugin requires Craft CMS 3.1.2 or later.
Installation
Plugin Store
Log into your control panel, hit up the 'Plugin Store', search for this plugin and install.
Composer
Open terminal, go to your Craft project folder and use composer to load this plugin. Once loaded you can install via the Craft Control Panel, go to Settings → Plugins, locate the plugin and hit “Install”.
cd /path/to/project
composer require fruitstudios/searchit
Creating a filter
Filters can be produced manually or dynamically and are made up of a JSON array containing rows with a label key (string) and a filter key (string or valid JSON). If the filter contains a string then it will pass that value to the search parameter on the element search. If you pass JSON to the filter than you can create multiple query parameters.
Creating a filter
Ordering and preview
You have two ways to setup filters. Manually or dynamically.
Using Twig (Recommended)
You can use the power of twig templating to create your filters. For example, if you want a filter entries by authors, then you can use the following...
{% for user in craft.users.all() %}
{{ ({
filter: {
authorId: user.id
},
label: user.fullName
})|json_encode() }}{{ not loop.last ? ',' }}
{% endfor %}
This essentially creates an element query like so...
{{ craft.entries.authorId(user.id).all() }}
Using JSON
Create a valid JSON array to build a filter
{ "filter":"page 1", "label":"Page 1" },
{ "filter":"page 2", "label":"Page 2" },
{ "filter":"page 3", "label":"Page 3" },
{ "filter":"page 4", "label":"Page 4" }
As the filter value is passing a string, this is essentially creating an element query like so...
{{ craft.entries.search('page 1').all() }}
As an include
If you prefer to keep your code in your templates/repo, then you can link directly to templates.
{% include '_includes/filters/rooms' ignore missing %}
Example usage
Here are a few examples of different filters for different elements. The possibilities are endless!
Entries
Create filters for authors, date, categories, etc..
Example: Filter by author...
How to get this filter...
{% for user in craft.users.all() %}
{{ ({
filter: {
authorId: user.id
},
label: user.fullName
})|json_encode() }}{{ not loop.last ? ',' }}
{% endfor %}
Categories
Create filters to narrow down categories by heirarchy.
Example: Filter by top level category...
How to get this filter...
{% for category in craft.categories.group(‘alcoholicDrinks’).level(1).all() %}
{{ ({
filter: {
descendantOf: category.id
},
label: category.title
})|json_encode() }}{{ not loop.last ? ‘,’ }}
{% endfor %}
Assets
Create filters for file types, extensions etc.
Example: Filter file type and extensions...
How to get these filters...
Kind filter
{ "filter":"kind:compressed", "label":"Zip" },
{ "filter":"kind:image", "label":"Images" }
Extension filter
{ "filter":"extension:jpg", "label":"JPG" },
{ "filter":"extension:png", "label":"PNG" },
{ "filter":"extension:gif", "label":"GIF" }
Roadmap
Support for Commerce coming very soon
Useful Resources
Craft CMS Search Documentation Docs
As with the regular Craft Search, if you suspect that your search indexes don’t have the latest and greatest data, you can have Craft rebuild them with the Rebuild Search Indexes tool in Settings. Docs
Brought to you by FRUIT
fruitstudios/searchit 适用场景与选型建议
fruitstudios/searchit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40.73k 次下载、GitHub Stars 达 28, 最近一次更新时间为 2018 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「search」 「cms」 「filters」 「Craft」 「elements」 「craftcms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fruitstudios/searchit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fruitstudios/searchit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fruitstudios/searchit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package to retrieve data from Google Search Console
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Supercharged text field validation.
Simple filters for laravel
统计信息
- 总下载量: 40.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 28
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2018-10-11





