|
@@ -119,49 +119,122 @@
|
|
|
<body>
|
|
|
<header class="uk-background-secondary uk-background-norepeat uk-background-cover uk-background-center-center uk-light" <?php if (General::Options('headerBackground') !== '' && (General::Options('headerColorChoose') == false || General::Options('headerColorChoose') == '')): ?>
|
|
|
style="background-image: url(<?php echo General::Options('headerBackground'); ?>);"<?php endif; ?>>
|
|
|
- <nav class="uk-navbar-container">
|
|
|
- <div class="uk-container">
|
|
|
- <div data-uk-navbar>
|
|
|
- <div class="uk-navbar-center">
|
|
|
- <?php if(General::Options('logoPic') == ''):?>
|
|
|
- <a class="uk-navbar-item uk-logo" href="<?php $this->options->siteUrl(); ?>"><?php if (General::Options('logoText')): ?><?php echo General::Options('logoText'); ?><?php else:?><?php echo $this->options->title;?><?php endif; ?></a>
|
|
|
- <?php else:?>
|
|
|
- <a class="uk-navbar-item uk-logo" href="<?php $this->options->siteUrl(); ?>"><img src="<?php echo General::Options('logoPic'); ?>" style="max-width:100%;"></a>
|
|
|
- <?php endif;?>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </nav>
|
|
|
-<div class="uk-section uk-section-small uk-section-hero uk-position-relative" data-uk-scrollspy="cls: uk-animation-slide-bottom-medium; repeat: false">
|
|
|
- <div class="uk-container">
|
|
|
- <h1 class="uk-text-center uk-margin-remove-top"><?php if (General::Options('headerText')): ?><?php echo General::Options('headerText'); ?><?php else:?>How can I help you?<?php endif; ?></h1>
|
|
|
- <div class="hero-search uk-margin-bottom">
|
|
|
- <div class="uk-position-relative">
|
|
|
- <form class="uk-search uk-search-default" name="searchCompleteForm" onsubmit="return false;">
|
|
|
- <span data-uk-search-icon="ratio: 1.2"></span>
|
|
|
- <input id="searchComplete" spellcheck=false autocorrect="off" autocomplete="off"
|
|
|
- autocapitalize="off" maxlength="2048" tabindex="1" class="uk-search-input uk-form-large uk-border-rounded" type="search"
|
|
|
- placeholder="Input keywords and Enter to search" autocomplete="off" data-minchars="1" data-maxitems="30">
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+<!-- <nav class="uk-navbar-container">-->
|
|
|
+<!-- <div class="uk-container">-->
|
|
|
+<!-- <div data-uk-navbar>-->
|
|
|
+<!-- <div class="uk-navbar-center">-->
|
|
|
+<!-- --><?php //if(General::Options('logoPic') == ''):?>
|
|
|
+<!-- <a class="uk-navbar-item uk-logo" href="--><?php //$this->options->siteUrl(); ?><!--">--><?php //if (General::Options('logoText')): ?><!----><?php //echo General::Options('logoText'); ?><!----><?php //else:?><!----><?php //echo $this->options->title;?><!----><?php //endif; ?><!--</a>-->
|
|
|
+<!-- --><?php //else:?>
|
|
|
+<!-- <a class="uk-navbar-item uk-logo" href="--><?php //$this->options->siteUrl(); ?><!--"><img src="--><?php //echo General::Options('logoPic'); ?><!--" style="max-width:100%;"></a>-->
|
|
|
+<!-- --><?php //endif;?>
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </nav>-->
|
|
|
+<?php
|
|
|
+$currentUrl = $_SERVER['REQUEST_URI'];
|
|
|
+
|
|
|
+?>
|
|
|
+ <?php if (strpos($currentUrl, 'category') !== false) { ?>
|
|
|
+ <div class="uk-section uk-section-small uk-section-hero uk-position-relative" data-uk-scrollspy="cls: uk-animation-slide-bottom-medium; repeat: false">
|
|
|
+ <div class="uk-container">
|
|
|
+<!-- <h1 class="uk-text-center uk-margin-remove-top">--><?php //if (General::Options('headerText')): ?><!----><?php //echo General::Options('headerText'); ?><!----><?php //else:?><!--How can I help you?--><?php //endif; ?><!--</h1>-->
|
|
|
+ <div class="hero-search ">
|
|
|
+ <div class="uk-position-relative" >
|
|
|
+ <form class="uk-search uk-search-default " id="searchCompleteForm" name="searchCompleteForm" onsubmit="return false;" style="display: flex; align-items: center; gap: 10px;background-color: ">
|
|
|
+ <div class="uk-inline" style="flex-grow: 1;">
|
|
|
+ <span data-uk-search-icon="ratio: 1.2"></span>
|
|
|
+ <input id="searchComplete" spellcheck=false autocorrect="off" autocomplete="off"
|
|
|
+ autocapitalize="off" maxlength="2048" tabindex="1" class="uk-search-input uk-form-medium uk-border-rounded" type="search"
|
|
|
+ placeholder="Keywords, Enter to search" autocomplete="off" data-minchars="1" data-maxitems="30" style="width: 100%;">
|
|
|
+ </div>
|
|
|
+ <button class="uk-button uk-button-primary uk-border-rounded" type="submit" aria-label="Search">
|
|
|
+ <span data-uk-icon="icon: search"></span>
|
|
|
+ </button>
|
|
|
+ </form>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ else if (strpos($currentUrl, 'archives') == true)
|
|
|
+ {
|
|
|
+
|
|
|
+ $category_id=General::getCategoryId($this->category);
|
|
|
+ $category_info= General::getCategoryInfo($category_id);
|
|
|
+
|
|
|
+ ?>
|
|
|
+ <div class="uk-section uk-section-small uk-section-hero uk-position-relative" data-uk-scrollspy="cls: uk-animation-slide-bottom-medium; repeat: false">
|
|
|
+ <div class="uk-container">
|
|
|
+ <div class="hero-search">
|
|
|
+ <div class="uk-position-relative" style="display: flex; justify-content: center; align-items: center; height: 40px;"> <!-- 设置固定高度 -->
|
|
|
+ <p style="margin: 0;"><?php echo $category_info['name'];?></p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ?>
|
|
|
+ <div class="uk-section uk-section-small uk-section-hero uk-position-relative" data-uk-scrollspy="cls: uk-animation-slide-bottom-medium; repeat: false">
|
|
|
+ <div class="uk-container">
|
|
|
+ <div class="hero-search">
|
|
|
+ <div class="uk-position-relative" style="display: flex; justify-content: center; align-items: center; height: 40px;"> <!-- 设置固定高度 -->
|
|
|
+ <p style="margin: 0;">Select a category to search.</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
<script>
|
|
|
$(document).ready(function() {
|
|
|
- $('#searchComplete').on('keypress', function(e) {
|
|
|
- // 判断是否按下回车键
|
|
|
- if (e.which === 13) {
|
|
|
- // 获取搜索框中的输入值
|
|
|
- var searchQuery = $(this).val();
|
|
|
- // 构建目标URL
|
|
|
- var targetUrl = '/index.php/search/' + encodeURIComponent(searchQuery)+'/?category=<?php echo General::getCategoryId($this->getArchiveSlug());?>';
|
|
|
- // 跳转到目标URL
|
|
|
- window.location.href = targetUrl;
|
|
|
+ // 监听搜索按钮的点击事件
|
|
|
+ $('button[type="submit"]').on('click', function(e) {
|
|
|
+ e.preventDefault(); // 阻止表单默认提交行为
|
|
|
+
|
|
|
+ // 获取搜索框中的输入值
|
|
|
+ var searchQuery = $('#searchComplete').val();
|
|
|
+
|
|
|
+
|
|
|
+ // 如果 searchQuery 为空,提示用户输入
|
|
|
+ if (!searchQuery.trim()) {
|
|
|
+ // 移除之前的提示信息(如果存在)
|
|
|
+ $('.search-error-message').remove();
|
|
|
+
|
|
|
+ // 插入提示信息
|
|
|
+ $('#searchCompleteForm').after(
|
|
|
+ '<div class="search-error-message uk-alert-danger uk-border-rounded uk-margin-small uk-padding-small" style="padding:8px;margin: 0px;">' +
|
|
|
+ 'Please enter a search term.' +
|
|
|
+ '</div>'
|
|
|
+ );
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ // 获取 category
|
|
|
+ var category = '<?php
|
|
|
+ $categoryId = General::getCategoryId($this->getArchiveSlug());
|
|
|
+ if (empty($categoryId)) {
|
|
|
+ // 如果从 General::getCategoryId 获取不到 category,尝试从 URL 参数中获取
|
|
|
+ $categoryId = isset($_GET['category']) ? $_GET['category'] : '';
|
|
|
+ }
|
|
|
+ echo $categoryId;
|
|
|
+ ?>';
|
|
|
+
|
|
|
+ // 构建目标URL
|
|
|
+ var targetUrl = '/index.php/search/' + encodeURIComponent(searchQuery) + '/?category=' + category;
|
|
|
+
|
|
|
+ // 跳转到目标URL
|
|
|
+ window.location.href = targetUrl;
|
|
|
});
|
|
|
});
|
|
|
</script>
|