M
M
matros972017-06-15 15:19:56
opencart
matros97, 2017-06-15 15:19:56

OpenCart search not working?

Good afternoon, I’m studying OpenCart 2 and I can’t understand why the search doesn’t work, I seem to be doing everything right, but it doesn’t work, I wrote <?=$search?>
in the header.tpl file and created the search.ptl file, here is the code

<div class="nav navbar-nav navbar-right">
                  <form class="navbar-form navbar-left" role="search" method="get" action="">
                    <div class="input-group">
                      <input type="text" class="form-control" value="<?= $search; ?>" placeholder="<?=$text_search; ?>">
                      <span class="input-group-btn">
                        <button type="submit" class="btn btn-default" name="go"><i class="glyphicon glyphicon-search"></i></button>
                      </span>
                    </div>
                  </form>
                </div>

what could be the problem,
as I understand it, I need to specify the action parameter

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zoozag, 2017-08-30
@zoozag

Here is the script that is responsible for the standard search opencart /catalog/view/javascript/common.js
...
$('#search input[name=\'search\']').parent().find('button').on('click', function() {
var url = $('base' .attr('href') + 'index.php?route=product/search';
var value = $('header #search input[name=\'search\']').val();
if (value ) { url += '&search=' + encodeURIComponent(value); }
location = url;
});
Those. you either need to add form id="search" or change the selector in common.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question