在智能搜索完成時執行
參數
變量 | 類型 | 注意 |
---|---|---|
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。