* Date: 2026-5-20
*/
if (!defined('ROOT_PATH')) { exit('Access Denied'); }
require_once __DIR__ . '/_functions.php';
$pageTitle = '搜索结果';
$keyword = trim((string) ($_GET['keyword'] ?? ''));
$resultList = [];
if ($keyword !== '') {
$like = '%' . $keyword . '%';
$articleResults = $db->fetchAll("SELECT id, title, summary, content, create_time, litpic FROM {$db->table('article')} WHERE status = 1 AND title LIKE ? ORDER BY create_time DESC LIMIT 12", [$like]);
foreach ($articleResults as $item) {
$item['result_type'] = 'article';
$item['result_label'] = '文章';
$resultList[] = $item;
}
$productResults = $db->fetchAll("SELECT id, title, summary, content, create_time, litpic FROM {$db->table('product')} WHERE status = 1 AND title LIKE ? ORDER BY create_time DESC LIMIT 12", [$like]);
foreach ($productResults as $item) {
$item['result_type'] = 'product';
$item['result_label'] = '产品';
$resultList[] = $item;
}
usort($resultList, function ($a, $b) {
return intval($b['create_time'] ?? 0) <=> intval($a['create_time'] ?? 0);
});
}
$heroImage = !empty($slides[0]['litpic']) ? $slides[0]['litpic'] : '';
require_once __DIR__ . '/_header.php';
?>