-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathsearch.phtml
executable file
·70 lines (66 loc) · 2.54 KB
/
search.phtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
?>
<?php
/**
* Blog sidebar search form template
*
* @var $block \Magefan\Blog\Block\Sidebar\Search
* @var $mfSecureRenderer \Magefan\Community\Api\SecureHtmlRendererInterface
*/
?>
<div class="widget block blog-search" data-bind="scope: 'blog-search'">
<div class="block-content">
<form class="form" id="blog_search_mini_form"
action="<?= $block->escapeUrl($block->getFormUrl()) ?>"
method="get">
<div class="field search">
<label class="label" for="blog_search">
<span><?= $block->escapeHtml(__('Search')) ?></span>
</label>
<div class="control mfsearch">
<input id="blog_search"
type="text"
name="q"
value="<?= $block->escapeHtml($block->getQuery()) ?>"
placeholder="<?= $block->escapeHtml(__('Search posts here...')) ?>"
class="input-text"
maxlength="128" role="combobox"
aria-haspopup="false"
aria-autocomplete="both"
autocomplete="off">
<?= $block->getChildHtml('form_additional') ?>
</div>
</div>
<div class="actions">
<button type="submit"
title="<?= $block->escapeHtml(__('Search')) ?>"
class="action search">
<span><?= $block->escapeHtml(__('Search')) ?></span>
</button>
</div>
</form>
</div>
</div>
<?php $script = "
document.addEventListener('DOMContentLoaded', function() {
var form = document.getElementById('blog_search_mini_form');
form.addEventListener('submit', function(event) {
event.preventDefault();
var bs = document.getElementById('blog_search');
var value = bs.value;
if (value) {
bs.remove();
var a = form.action;
form.action = a + ( ('/' != a.charAt(a.length - 1)) ? '/' : '' ) + encodeURI(value) + '/';
}
form.submit()
});
});
"; ?>
<?= /* @noEscape */ $mfSecureRenderer->renderTag('script', [], $script, false) ?>