Add search functional

This commit is contained in:
Mesin Kasir 2023-03-15 07:30:12 +07:00 committed by GitHub
parent a177c41ecd
commit c7dbdc7355
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,4 +2,24 @@
<div class="col-md-12 p-3 border-bottom border-gray-light">
<h1><strong><a href="<?php echo $site->url(); ?>"><?php echo $site->title(); ?></a></strong></h1>
<h2><?php echo $site->description(); ?></h2>
</div>
<?php if (pluginActivated('pluginSearch')): ?>
<div class="form-inline d-block">
<input id="search-input" class="form-control mr-sm-2" type="search" placeholder="<?php $language->p('Search') ?>" aria-label="Search">
<button class="btn btn-outline-dark my-2 my-sm-0" type="button" onClick="searchNow()"><?php $language->p('Search') ?></button>
<script>
function searchNow() {
var searchURL = "<?php echo Theme::siteUrl(); ?>search/";
window.open(searchURL + document.getElementById("search-input").value, "_self");
}
document.getElementById("search-input").onkeypress = function(e) {
if (!e) e = window.event;
var keyCode = e.keyCode || e.which;
if (keyCode == '13') {
searchNow();
return false;
}
}
</script>
</div>
<?php endif ?>
</div>