在智能搜索完成时执行
参数
变量 | 类型 | 注意 |
---|---|---|
searchTerm | string | 正在搜索的词 |
numResults | int | 要返回的结果数 |
响应
一组额外的搜索结果。请参阅数组结构的示例。 WHMCS 7.7 之前的版本支持字符串响应。
示例代码
<?php
add_hook('IntelligentSearch', 1, function ($vars) {
/**
* This is an example of array return for an Intelligent Search.
* This format is supported in the blend WHMCS Admin Template.
* Any template based on blend and updated to WHMCS 7.7+ is also supported.
*/
$searchResults = array();
// look for exact matches in client notes field
$result = \WHMCS\Database\Capsule::table('tblclients')
->where('notes', $vars['searchTerm'])
->get();
foreach ($result as $client) {
$searchResults[] = [
'title' => $client->firstname . ' ' . $client->lastname, // The title of the search result. This is required.
'href' => 'clientssummary.php?userid=' . $client->id, // The destination url of the search result. This is required.
'subTitle' => $client->email, // An optional subtitle for the search result.
'icon' => 'fal fa-user', // A font-awesome icon for the search result. Defaults to 'fal fa-star' if not defined.
];
}
return $searchResults;
});
相关用法
- PHP Integer转String用法及代码示例
- PHP IntlCalendar getTimeZone()用法及代码示例
- PHP IntlCalendar getActualMinimum()用法及代码示例
- PHP IntlChar isMirrored()用法及代码示例
- PHP IntlChar isdefined()用法及代码示例
- PHP IntlChar getUnicodeVersion()用法及代码示例
- PHP IntlChar foldCase()用法及代码示例
- PHP IntlChar isgraph()用法及代码示例
- PHP IntlChar::isxdigit()用法及代码示例
- PHP IntlChar getPropertyValueName()用法及代码示例
- PHP IntlChar hasBinaryProperty()用法及代码示例
- PHP IntlChar::isblank()用法及代码示例
- PHP IntlChar enumCharTypes()用法及代码示例
- PHP IntlChar::isJavaSpaceChar()用法及代码示例
- PHP IntlChar getIntPropertyMinValue()用法及代码示例
- PHP IntlChar::isUAlphabetic()用法及代码示例
- PHP IntlChar getPropertyValueEnum()用法及代码示例
- PHP IntlChar::isIDStart()用法及代码示例
- PHP IntlChar::isspace()用法及代码示例
- PHP IntlChar::forDigit()用法及代码示例
- PHP IntlChar getCombiningClass()用法及代码示例
- PHP IntlCalendar add()用法及代码示例
- PHP IntlChar::iscntrl()用法及代码示例
- PHP IntlChar::ispunct()用法及代码示例
- PHP IntlChar istitle()用法及代码示例
注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 IntelligentSearch。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。